From ae8b09b77668bec49cc9331114e98dbfad8f9215 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Thu, 20 Jul 2017 10:16:32 +0800 Subject: [PATCH 01/18] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20=E7=BC=A9=E6=94=BE=E6=9D=A1?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/mainframe/JSliderPane.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/mainframe/JSliderPane.java b/designer_base/src/com/fr/design/mainframe/JSliderPane.java index 7125b53b10..18ab15a0bc 100644 --- a/designer_base/src/com/fr/design/mainframe/JSliderPane.java +++ b/designer_base/src/com/fr/design/mainframe/JSliderPane.java @@ -29,6 +29,7 @@ public class JSliderPane extends JPanel { private static final int SIX = 6; private static final int TEN = 10; private static final int ONEEIGHT = 18; + private static final int TWOFIVE = 25; private static final int FOURTEN = 40; private static final int HALFHUNDRED = 50; private static final int HUNDRED = 100; @@ -82,7 +83,7 @@ public class JSliderPane extends JPanel { showValButton = new UIButton(showVal.getText()); showValButton.setBorderPainted(false); - showValButton.setPreferredSize(new Dimension(HALFHUNDRED,ONEEIGHT)); + showValButton.setPreferredSize(new Dimension(HALFHUNDRED,TWOFIVE)); showValButton.addActionListener(new ActionListener() { @Override From ffe8977ddd97ab8864cde9e52d90e8febadc87a5 Mon Sep 17 00:00:00 2001 From: plough Date: Fri, 21 Jul 2017 09:44:39 +0800 Subject: [PATCH 02/18] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=A4=96=E6=A1=86=E6=9E=B6=E5=B7=A5=E5=85=B7=E6=9D=A1UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/icontainer/UIEastResizableContainer.java | 7 ++++--- .../com/fr/design/mainframe/EastRegionContainerPane.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/icontainer/UIEastResizableContainer.java b/designer_base/src/com/fr/design/gui/icontainer/UIEastResizableContainer.java index 3a24e39027..85e11d8d7b 100644 --- a/designer_base/src/com/fr/design/gui/icontainer/UIEastResizableContainer.java +++ b/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); } } diff --git a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java index aac6850767..bdd03b3c57 100644 --- a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java @@ -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); } From 6ad1e6adcf49779d83589cbd7f94e08183136714 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Fri, 21 Jul 2017 11:13:44 +0800 Subject: [PATCH 03/18] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20=E7=BC=A9=E6=94=BE=E6=9D=A1?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/cell/bar/DynamicScrollBar.java | 6 + .../fr/design/mainframe/ElementCasePane.java | 2 - .../com/fr/design/mainframe/JWorkBook.java | 66 +++-- .../fr/design/mainframe/ReportComponent.java | 4 + .../mainframe/ReportComponentCardPane.java | 2 +- .../mainframe/ReportComponentComposite.java | 26 +- .../com/fr/design/present/BarCodePane.java | 11 + .../grid/AbstractGridHeaderMouseHandler.java | 35 +-- designer/src/com/fr/grid/Grid.java | 4 + designer/src/com/fr/grid/GridColumn.java | 20 +- .../com/fr/grid/GridColumnMouseHandler.java | 9 +- designer/src/com/fr/grid/GridHeader.java | 12 + designer/src/com/fr/grid/GridRow.java | 14 +- .../com/fr/design/mainframe/JSliderPane.java | 229 ++++++++++-------- .../com/fr/design/mainframe/JTemplate.java | 2 + .../src/com/fr/design/mainframe/FormArea.java | 36 +-- .../src/com/fr/design/mainframe/JForm.java | 5 + 17 files changed, 302 insertions(+), 181 deletions(-) diff --git a/designer/src/com/fr/design/cell/bar/DynamicScrollBar.java b/designer/src/com/fr/design/cell/bar/DynamicScrollBar.java index bf61f7a5e7..11f8e51b0d 100644 --- a/designer/src/com/fr/design/cell/bar/DynamicScrollBar.java +++ b/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(); diff --git a/designer/src/com/fr/design/mainframe/ElementCasePane.java b/designer/src/com/fr/design/mainframe/ElementCasePane.java index d55fcd4472..17dfa8442d 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePane.java +++ b/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; diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index 5978a506fd..0a75350676 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/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; @@ -70,6 +68,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; @@ -334,20 +333,51 @@ public class JWorkBook extends JTemplate { public void setScale(int resolution) { //更新resolution this.resolution = resolution; - reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().getGridMouseAdapter().setResolution(resolution); - reportComposite.centerCardPane.editingComponet.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.setVerticalExtent(GridUtils.getExtentValue(0, rowHeightList, grid.getHeight(), resolution)); - grid.setHorizontalExtent(GridUtils.getExtentValue(0, columnWidthList, grid.getWidth(), resolution)); - reportComposite.centerCardPane.editingComponet.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(); + if (reportComposite.centerCardPane.editingComponet.elementCasePane != null){ + reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().getGridMouseAdapter().setResolution(resolution); + reportComposite.centerCardPane.editingComponet.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.setVerticalExtent(GridUtils.getExtentValue(0, rowHeightList, grid.getHeight(), resolution)); + grid.setHorizontalExtent(GridUtils.getExtentValue(0, columnWidthList, grid.getWidth(), resolution)); + reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().updateUI(); + //更新Column和Row + ((DynamicScrollBar)reportComposite.centerCardPane.editingComponet.elementCasePane.getVerticalScrollBar()).setDpi(resolution); + ((DynamicScrollBar)reportComposite.centerCardPane.editingComponet.elementCasePane.getHorizontalScrollBar()).setDpi(resolution); + 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(); + } + if (reportComposite.centerCardPane.polyDezi != null){ + reportComposite.centerCardPane.polyDezi.setResolution(resolution); + reportComposite.centerCardPane.polyDezi.updateUI(); + } +// reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().setVerticalValue(10); + + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified(); + } + @Override + public int selfAdaptUpdate(){ + ElementCasePane reportPane = reportComposite.centerCardPane.editingComponet.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 * reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().getResolution()); } @Override diff --git a/designer/src/com/fr/design/mainframe/ReportComponent.java b/designer/src/com/fr/design/mainframe/ReportComponent.java index 6ca2685454..42342f24e7 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponent.java +++ b/designer/src/com/fr/design/mainframe/ReportComponent.java @@ -27,9 +27,13 @@ import com.fr.design.selection.Selectedable; */ public abstract class ReportComponent extends TargetComponent implements Selectedable { protected E elementCasePane; +// protected P polyElementCasePane; public E getEditingElementCasePane() { return elementCasePane; } +// public P getEditingPolyElementCasePane() { +// return polyElementCasePane; +// } public ReportComponent(T t) { super(t); } diff --git a/designer/src/com/fr/design/mainframe/ReportComponentCardPane.java b/designer/src/com/fr/design/mainframe/ReportComponentCardPane.java index 54c7f7657f..cc45cf5e90 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentCardPane.java +++ b/designer/src/com/fr/design/mainframe/ReportComponentCardPane.java @@ -25,7 +25,7 @@ public class ReportComponentCardPane extends JComponent implements TargetModifie private CardLayout cl; private WorkSheetDesigner sheetDezi; - private PolyDesigner polyDezi; + protected PolyDesigner polyDezi; public ReportComponentCardPane() { this.setLayout(cl = new CardLayout()); diff --git a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java index d51db17709..36418924b8 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java @@ -1,11 +1,15 @@ package com.fr.design.mainframe; import java.awt.BorderLayout; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.util.ArrayList; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JSplitPane; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; @@ -15,6 +19,7 @@ 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; @@ -60,25 +65,28 @@ 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); } - DocumentListener jSliderContainerListener = new DocumentListener() { + ChangeListener showValSpinnerChangeListener = new ChangeListener() { @Override - public void insertUpdate(DocumentEvent e) { - double value = Integer.parseInt(jSliderContainer.getShowVal().getText().substring(0, jSliderContainer.getShowVal().getText().indexOf("%"))); + public void stateChanged(ChangeEvent e) { + double value = (int) ((UIBasicSpinner)e.getSource()).getValue(); value = value>MAX ? MAX : value; value = value { addlistener(); } + 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(new BarCodePane(),BorderLayout.CENTER); + GUICoreUtils.centerWindow(jf); + jf.setSize(270, 400); + jf.setVisible(true); + } + private void initComponents() { barCodePreviewPane = new BarCodePreviewPane(); this.barWidthSpinner = new UIBasicSpinner(new SpinnerNumberModel(1, 1, 100, 0.1)); diff --git a/designer/src/com/fr/grid/AbstractGridHeaderMouseHandler.java b/designer/src/com/fr/grid/AbstractGridHeaderMouseHandler.java index 42f7417b54..b68ddd197a 100644 --- a/designer/src/com/fr/grid/AbstractGridHeaderMouseHandler.java +++ b/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,10 +52,16 @@ 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) { this.startMultiSelectIndex = 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) { diff --git a/designer/src/com/fr/grid/Grid.java b/designer/src/com/fr/grid/Grid.java index 6bade0e2e4..01a2bb1d84 100644 --- a/designer/src/com/fr/grid/Grid.java +++ b/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; + } + /** * 应用界面设置 * diff --git a/designer/src/com/fr/grid/GridColumn.java b/designer/src/com/fr/grid/GridColumn.java index eedf8bcaf2..165a5727a9 100644 --- a/designer/src/com/fr/grid/GridColumn.java +++ b/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 { - 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 { @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 { this.resolution = resolution; } + @Override + public int getResolution() { + return this.resolution; + } + /** * Gets the preferred size. */ diff --git a/designer/src/com/fr/grid/GridColumnMouseHandler.java b/designer/src/com/fr/grid/GridColumnMouseHandler.java index b7864bf051..2d93d01d29 100644 --- a/designer/src/com/fr/grid/GridColumnMouseHandler.java +++ b/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) { diff --git a/designer/src/com/fr/grid/GridHeader.java b/designer/src/com/fr/grid/GridHeader.java index 754257e2f6..b0dca649da 100644 --- a/designer/src/com/fr/grid/GridHeader.java +++ b/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 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 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) ; diff --git a/designer/src/com/fr/grid/GridRow.java b/designer/src/com/fr/grid/GridRow.java index 4c42ce6306..28a97e1709 100644 --- a/designer/src/com/fr/grid/GridRow.java +++ b/designer/src/com/fr/grid/GridRow.java @@ -23,10 +23,13 @@ public class GridRow extends GridHeader { 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 { @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 { this.resolution = resolution; } + public int getResolution() { + return this.resolution; + } + /** * Gets the preferred size. diff --git a/designer_base/src/com/fr/design/mainframe/JSliderPane.java b/designer_base/src/com/fr/design/mainframe/JSliderPane.java index 18ab15a0bc..c4cdf377f4 100644 --- a/designer_base/src/com/fr/design/mainframe/JSliderPane.java +++ b/designer_base/src/com/fr/design/mainframe/JSliderPane.java @@ -1,11 +1,15 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; +import com.fr.design.file.HistoryTemplateListPane; 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,8 +17,6 @@ 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.*; @@ -29,6 +31,9 @@ public class JSliderPane extends JPanel { private static final int SIX = 6; private static final int TEN = 10; private static final int ONEEIGHT = 18; + private static final int FONTSIZE = 14; + private static final int SPINNERWIDTH= 45; + private static final int SPINNERHEIGHT = 20; private static final int TWOFIVE = 25; private static final int FOURTEN = 40; private static final int HALFHUNDRED = 50; @@ -37,11 +42,14 @@ public class JSliderPane extends JPanel { 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 DIALOGHEIGHT = 240; + private static final int SHOWVALBUTTONWIDTH = 70; + private static final int SHOWVALBUTTONHEIGHTH = 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; @@ -59,6 +67,7 @@ public class JSliderPane extends JPanel { private boolean isButtonOrIsTxt = true; private PopupPane dialog; private int upButtonX; + private JPanel dialogContentPanel; public JSliderPane() { @@ -67,11 +76,18 @@ public class JSliderPane extends JPanel { 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, FOURHUNDRED, 1)); + showValSpinner.setEnabled(true); + showValSpinner.addChangeListener(showValSpinnerChangeListener); + showValSpinner.setPreferredSize(new Dimension(SPINNERWIDTH, SPINNERHEIGHT)); + //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"); @@ -79,25 +95,20 @@ 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,TWOFIVE)); + showValButton.setPreferredSize(new Dimension(SHOWVALBUTTONWIDTH,SHOWVALBUTTONHEIGHTH)); + showValButton.addActionListener(showValButtonActionListener); - showValButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - popupDialog(); - } - }); + 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); - } public static final JSliderPane getInstance() { @@ -116,6 +127,13 @@ 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")); + 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);// 加入按钮组 @@ -125,8 +143,53 @@ 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, FONTSIZE)); + 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); + refreshSlider(val); + refreshBottun(val); + } + }; + //定义一个监听器,用于监听所有滑动条 ChangeListener listener = new ChangeListener() @@ -134,13 +197,13 @@ public class JSliderPane extends JPanel { public void stateChanged( ChangeEvent event) { //取出滑动条的值,并在文本中显示出来 if (!isButtonOrIsTxt){ - JSlider source = (JSlider) event.getSource(); + customButton.setSelected(true); EventQueue.invokeLater(new Runnable() { public void run() { sliderValue = slider.getValue(); getTimes(sliderValue); showValue = times; - showVal.setText(times + "%"); + showValSpinner.setValue(times); } }); }else { @@ -149,28 +212,18 @@ public class JSliderPane extends JPanel { } }; - DocumentListener showValDocumentListener = new DocumentListener() { + ItemListener radioButtonItemListener = new ItemListener() { @Override - public void insertUpdate(DocumentEvent e) { - isButtonOrIsTxt = true; - resolutionTimes = divide(showValue,100,2); - refreshSlider(); - refreshBottun(); - } - - @Override - public void removeUpdate(DocumentEvent e) { -// refreshSlider(); - } - - @Override - public void changedUpdate(DocumentEvent e) { -// refreshSlider(); + 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(){ - showValue = Integer.parseInt(showVal.getText().substring(0, showVal.getText().indexOf("%"))); + private void refreshSlider(int val){ + showValue = val; if (showValue >HUNDRED){ slider.setValue((int)(showValue+TWOHUNDRED)/SIX); }else if (showValue = TEN ){ showValue = newDownVal; - showVal.setText(newDownVal + "%"); + showValSpinner.setValue(newDownVal); }else { showValue = newDownVal; - showVal.setText(TEN + "%"); + showValSpinner.setValue(TEN); } } if(e.getActionCommand().equals("more")){ int newUpVal = showValue + TEN; if (newUpVal <= FOURHUNDRED ){ showValue = newUpVal; - showVal.setText(newUpVal + "%"); + showValSpinner.setValue(newUpVal); }else { showValue = newUpVal; - showVal.setText(FOURHUNDRED + "%"); + showValSpinner.setValue(FOURHUNDRED); } } isButtonOrIsTxt = true; + customButton.setSelected(true); } }; @@ -241,38 +295,42 @@ public class JSliderPane extends JPanel { } - public UITextField getShowVal(){ - return this.showVal; + public JSpinner getShowVal(){ + return this.showValSpinner; + } + + public UIRadioButton getSelfAdaptButton(){ + return this.selfAdaptButton; } private void popupDialog(){ Point btnCoords = upButton.getLocationOnScreen(); if (dialog == null){ - dialog = new PopupPane(upButton,showVal); + dialog = new PopupPane(upButton,dialogContentPanel); if (upButtonX == 0) { upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() + SHOWVALBUTTONWIDTH , -DIALOGHEIGHT); } }else { if (upButtonX == 0) { upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +SHOWVALBUTTONWIDTH, -DIALOGHEIGHT); } else { - GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +SHOWVALBUTTONWIDTH, -DIALOGHEIGHT); } } } 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(JSliderPane.getInstance(),BorderLayout.CENTER); - GUICoreUtils.centerWindow(jf); - jf.setSize(400, 80); - jf.setVisible(true); +// JFrame jf = new JFrame("test"); +// jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); +// JPanel content = (JPanel)jf.getContentPane(); +// content.setLayout(new BorderLayout()); +// content.add(JSliderPane.getInstance(),BorderLayout.CENTER); +// GUICoreUtils.centerWindow(jf); +// jf.setSize(400, 80); +// jf.setVisible(true); } } @@ -345,66 +403,25 @@ class JSliderPaneUI extends BasicSliderUI { } } -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 DIALOGHEIGHT = 240; private static final int UPLABELWIDTH = 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.setBackground(Color.LIGHT_GRAY); upLabel.setBorder(new MatteBorder(0,0,1,0,Color.gray)); - centerPane.add(j,BorderLayout.NORTH); + 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)); diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index a5023be824..309fac533d 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -217,6 +217,8 @@ public abstract class JTemplate> ex public abstract int getScale(); + public abstract int selfAdaptUpdate(); + protected abstract DesignModelAdapter createDesignModel(); /** diff --git a/designer_form/src/com/fr/design/mainframe/FormArea.java b/designer_form/src/com/fr/design/mainframe/FormArea.java index 0d0e05f045..b7853183e1 100644 --- a/designer_form/src/com/fr/design/mainframe/FormArea.java +++ b/designer_form/src/com/fr/design/mainframe/FormArea.java @@ -31,6 +31,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; @@ -153,11 +154,13 @@ public class FormArea extends JComponent implements ScrollRulerComponent { private void initTransparent() { initCalculateSize(); - slidePane.getShowVal().getDocument().addDocumentListener(new DocumentListener() { - @Override - public void insertUpdate(DocumentEvent e) { -// slidePane.getShowVal().getDocument() - double value = Integer.parseInt(slidePane.getShowVal().getText().substring(0, slidePane.getShowVal().getText().indexOf("%"))); + slidePane.getShowVal().addChangeListener(showValSpinnerChangeListener); + } + + ChangeListener showValSpinnerChangeListener = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + double value = (int) ((UIBasicSpinner)e.getSource()).getValue(); value = value>SHOWVALMAX ? SHOWVALMAX : value; value = value implements BaseJForm { return 0; } + @Override + public int selfAdaptUpdate() { + return 0; + } + /** * 创建权限细粒度编辑面板 * From 07c5057047bbbaf766d03aa2c3d2914557131eb7 Mon Sep 17 00:00:00 2001 From: plough Date: Fri, 21 Jul 2017 14:06:42 +0800 Subject: [PATCH 04/18] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E5=B0=86=E8=B6=85?= =?UTF-8?q?=E7=BA=A7=E9=93=BE=E6=8E=A5=E9=9D=A2=E6=9D=BF=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=8D=95=E4=BE=8B=EF=BC=8C=E6=8F=92=E5=85=A5=E5=8F=B3=E4=BE=A7?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E9=9D=A2=E6=9D=BF=E6=A1=86=E6=9E=B6=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/ElementCasePaneDelegate.java | 3 + .../com/fr/design/mainframe/JWorkBook.java | 6 ++ .../mainframe/ReportHyperlinkGroupPane.java | 55 +++++++++++++++++++ .../design/gui/frpane/HyperlinkGroupPane.java | 3 +- .../mainframe/EastRegionContainerPane.java | 8 +++ .../com/fr/design/mainframe/JTemplate.java | 4 +- .../gui/xpane/FormHyperlinkGroupPane.java | 16 +++++- .../src/com/fr/design/mainframe/JForm.java | 2 +- 8 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 designer/src/com/fr/design/mainframe/ReportHyperlinkGroupPane.java diff --git a/designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java b/designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java index 4336282091..f515643be2 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java +++ b/designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java @@ -58,6 +58,8 @@ public class ElementCasePaneDelegate extends ElementCasePane { 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()); @@ -66,6 +68,7 @@ public class ElementCasePaneDelegate extends ElementCasePane { EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT); EastRegionContainerPane.getInstance().replaceCellAttrPane(CellElementPropertyPane.getInstance()); EastRegionContainerPane.getInstance().replaceCellElementPane(QuickEditorRegion.getInstance()); + EastRegionContainerPane.getInstance().replaceHyperlinkPane(ReportHyperlinkGroupPane.getInstance()); } EastRegionContainerPane.getInstance().removeParameterPane(); } diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index 5978a506fd..11ceb595d5 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -23,6 +23,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; @@ -755,6 +756,11 @@ public class JWorkBook extends JTemplate { return true; } + @Override + public HyperlinkGroupPane getHyperLinkPane() { + return ReportHyperlinkGroupPane.getInstance(); + } + public void setAuthorityMode(boolean isUpMode) { centerPane.setAuthorityMode(isUpMode); } diff --git a/designer/src/com/fr/design/mainframe/ReportHyperlinkGroupPane.java b/designer/src/com/fr/design/mainframe/ReportHyperlinkGroupPane.java new file mode 100644 index 0000000000..64c397da1b --- /dev/null +++ b/designer/src/com/fr/design/mainframe/ReportHyperlinkGroupPane.java @@ -0,0 +1,55 @@ +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) { +// TemplateElementCase elementCase = ePane.getEditingElementCase(); +// if (elementCase == null) { +// return; +// } +// ePane.getSelection().populatePropertyPane(ePane); + 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; + } +} diff --git a/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java b/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java index 3408bf371d..d0a824074a 100644 --- a/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java @@ -23,8 +23,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 JListControlPane { /** * 生成添加按钮的NameableCreator * diff --git a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java index bdd03b3c57..5970c60ead 100644 --- a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java @@ -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); } diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index a5023be824..72778113b1 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -867,9 +867,7 @@ public abstract class JTemplate> ex * 返回当前支持的超链界面pane * @return 超链连接界面 */ - public HyperlinkGroupPane getHyperLinkPane() { - return new HyperlinkGroupPane(); - } + public abstract HyperlinkGroupPane getHyperLinkPane(); /** * 是否是图表 diff --git a/designer_form/src/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java b/designer_form/src/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java index 773446f5af..61b0c7aa96 100644 --- a/designer_form/src/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java +++ b/designer_form/src/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java @@ -8,8 +8,20 @@ import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.js.EmailJavaScript; -public class FormHyperlinkGroupPane extends HyperlinkGroupPane{ - +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 * 由于表单报表块的单元格超链和单元格条件属性超链中的emailPane都要用表单的emailPane,这里调整下 diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index 234dad22fa..7de4557cfb 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -124,7 +124,7 @@ public class JForm extends JTemplate implements BaseJForm { * @return 超链连接界面 */ public HyperlinkGroupPane getHyperLinkPane() { - return new FormHyperlinkGroupPane(); + return FormHyperlinkGroupPane.getInstance(); } //表单返回 FORM_TAB or ELEMENTCASE_TAB From 92206ac3d8cf324de854aeff507c97b972e98a62 Mon Sep 17 00:00:00 2001 From: plough Date: Fri, 21 Jul 2017 14:13:44 +0800 Subject: [PATCH 05/18] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E5=85=83=E7=B4=A0=E8=B6=85=E7=BA=A7=E9=93=BE=E6=8E=A5tab?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/mainframe/ElementCasePaneDelegate.java | 2 +- .../src/com/fr/design/mainframe/EastRegionContainerPane.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java b/designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java index f515643be2..5253999ac8 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java +++ b/designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java @@ -68,8 +68,8 @@ public class ElementCasePaneDelegate extends ElementCasePane { EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT); EastRegionContainerPane.getInstance().replaceCellAttrPane(CellElementPropertyPane.getInstance()); EastRegionContainerPane.getInstance().replaceCellElementPane(QuickEditorRegion.getInstance()); - EastRegionContainerPane.getInstance().replaceHyperlinkPane(ReportHyperlinkGroupPane.getInstance()); } + EastRegionContainerPane.getInstance().replaceHyperlinkPane(ReportHyperlinkGroupPane.getInstance()); EastRegionContainerPane.getInstance().removeParameterPane(); } } diff --git a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java index 5970c60ead..a0a3b8828d 100644 --- a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/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}, From 4929f8efad92520801d79bc2583ef1dc1e1e9df2 Mon Sep 17 00:00:00 2001 From: plough Date: Fri, 21 Jul 2017 16:50:17 +0800 Subject: [PATCH 06/18] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E6=96=B0=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E9=9D=A2=E6=9D=BF=E9=9B=8F=E5=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/controlpane/UIControlPane.java | 232 +++++ .../gui/controlpane/UIListControlPane.java | 945 ++++++++++++++++++ .../UINameableListCellRenderer.java | 146 +++ .../design/gui/frpane/HyperlinkGroupPane.java | 3 +- 4 files changed, 1325 insertions(+), 1 deletion(-) create mode 100644 designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java create mode 100644 designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java create mode 100644 designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java new file mode 100644 index 0000000000..f67512d92f --- /dev/null +++ b/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java @@ -0,0 +1,232 @@ +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.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; + // 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"); + // 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); +// 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(); + toolbarDef.updateToolBar(toolBar); + leftContentPane.add(toolBar, BorderLayout.NORTH); + + // 顶部标签及add按钮 + UIToolbar topToolBar = new UIToolbar(); + topToolBar.setLayout(new BorderLayout()); + ShortCut addItem = addItemShortCut().getShortCut(); + addItem.intoJToolBar(topToolBar); + 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); + 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(); + } +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java new file mode 100644 index 0000000000..c36a7902c2 --- /dev/null +++ b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java @@ -0,0 +1,945 @@ +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.icontainer.UIScrollPane; +import com.fr.design.gui.ilist.JNameEdList; +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"; + + protected JNameEdList 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 JNameEdList createJNameList() { + JNameEdList nameEdList = new JNameEdList(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 res = new java.util.ArrayList(); + ((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,选中JNameEdList中的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) { + JNameEdList 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++; + } + } + + /** + * 增加项的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); + } + + 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 nameableComparator = new Comparator() { + @Override + public int compare(Nameable o1, Nameable o2) { + return -ComparatorUtils.compare(o1.getName(), o2 + .getName()); + } + }; + isAtoZ = !isAtoZ; + Arrays.sort(nameableArray, nameableComparator); + } else { + Comparator nameableComparator = new Comparator() { + @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(); + } + } + + /* + * JNameEdList的鼠标事件 + */ + private MouseListener listMouseListener = new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent evt) { + nameableList.stopEditing(); + if (evt.getClickCount() >= 2 + && SwingUtilities.isLeftMouseButton(evt)) { + editingIndex = nameableList.getSelectedIndex(); + selectedName = nameableList.getNameAt(editingIndex); + nameableList.editItemAt(nameableList.getSelectedIndex()); + } + // 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); + } + +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java b/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java new file mode 100644 index 0000000000..df672e8a1d --- /dev/null +++ b/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java @@ -0,0 +1,146 @@ +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.stable.Nameable; +import sun.swing.DefaultLookup; + +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import java.awt.*; + +/** + * 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); + protected static Border noFocusBorder = DEFAULT_NO_FOCUS_BORDER; + private static final int BUTTON_WIDTH = 40; + private UIButton editButton; + 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 UIButton("edit") { + public Dimension getPreferredSize() { + return new Dimension(BUTTON_WIDTH, BUTTON_WIDTH); + } + }; + editButton.set4LargeToolbarButton(); + label = new UILabel(); +// label.setEditable(false); + this.setLayout(new BorderLayout()); + this.add(editButton, BorderLayout.WEST); + this.add(label, BorderLayout.CENTER); + } + + private Border getNoFocusBorder() { + 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; + } +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java b/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java index d0a824074a..fcd9ba3833 100644 --- a/designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java +++ b/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,7 +24,7 @@ import java.util.Set; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2013-6-25 上午11:17:57 */ -public abstract class HyperlinkGroupPane extends JListControlPane { +public abstract class HyperlinkGroupPane extends UIListControlPane { /** * 生成添加按钮的NameableCreator * From f89951424a1b205101fa4070bb90840deda4996e Mon Sep 17 00:00:00 2001 From: MoMeak Date: Sun, 23 Jul 2017 23:40:28 +0800 Subject: [PATCH 07/18] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20=E8=81=9A=E5=90=88=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E7=BC=A9=E6=94=BE=E6=9D=A1=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JWorkBook.java | 64 ++++++++++---- .../mainframe/ReportComponentComposite.java | 2 +- designer/src/com/fr/poly/PolyArea.java | 18 +++- designer/src/com/fr/poly/PolyDesignUI.java | 87 ++++++++++++------- designer/src/com/fr/poly/PolyDesigner.java | 62 +++++++------ .../src/com/fr/poly/creator/BlockCreator.java | 4 + .../src/com/fr/poly/creator/BlockEditor.java | 2 +- .../fr/poly/creator/ChartBlockCreator.java | 14 ++- .../com/fr/poly/creator/ChartBlockEditor.java | 13 ++- .../com/fr/poly/creator/ECBlockEditor.java | 5 ++ .../com/fr/design/mainframe/JTemplate.java | 13 ++- .../fr/design/chart/gui/ChartComponent.java | 13 ++- .../src/com/fr/design/mainframe/JForm.java | 10 +++ 13 files changed, 219 insertions(+), 88 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index 0a75350676..8251368849 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -56,6 +56,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; @@ -147,6 +148,16 @@ public class JWorkBook extends JTemplate { return processInfo; } + @Override + public void setJTemplateResolution(int resolution) { + this.resolution = resolution; + } + + @Override + public int getJTemplateResolution() { + return this.resolution; + } + /** * 判断sheet权限 * @@ -353,6 +364,7 @@ public class JWorkBook extends JTemplate { } if (reportComposite.centerCardPane.polyDezi != null){ reportComposite.centerCardPane.polyDezi.setResolution(resolution); + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setJTemplateResolution(resolution); reportComposite.centerCardPane.polyDezi.updateUI(); } // reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().setVerticalValue(10); @@ -361,23 +373,45 @@ public class JWorkBook extends JTemplate { } @Override public int selfAdaptUpdate(){ - ElementCasePane reportPane = reportComposite.centerCardPane.editingComponet.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){ + if (resolution == 0){ + resolution = ScreenResolution.getScreenResolution(); + } + if (reportComposite.centerCardPane.polyDezi.getSelection() !=null){ + BlockCreator blockCreator =reportComposite.centerCardPane.polyDezi.getSelection(); + double x = blockCreator.getEditorBounds().getX(); + double y = blockCreator.getEditorBounds().getY(); + reportComposite.centerCardPane.polyDezi.setHorizontalValue((int) x); + reportComposite.centerCardPane.polyDezi.setVerticalValue((int) y); + double creatorHeight = blockCreator.getEditorBounds().height; + double creatorWidth = blockCreator.getEditorBounds().width; + double areaHeight = reportComposite.centerCardPane.polyDezi.polyArea.getHeight(); + double areaWidth = reportComposite.centerCardPane.polyDezi.polyArea.getWidth(); + if (creatorWidth == 0||creatorHeight == 0){ + return resolution; + } + double time =(areaHeight/creatorHeight)<(areaWidth/creatorWidth) ? (areaHeight/creatorHeight) : (areaWidth/creatorWidth); + return (int) (time * reportComposite.centerCardPane.polyDezi.getResolution()); + + }else if (reportComposite.centerCardPane.editingComponet.elementCasePane != null) { + ElementCasePane reportPane = reportComposite.centerCardPane.editingComponet.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 * reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().getResolution()); + }else { 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 * reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().getResolution()); } @Override diff --git a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java index 36418924b8..1b4fcdd1d2 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java @@ -85,7 +85,7 @@ public class ReportComponentComposite extends JComponent { public void itemStateChanged(ItemEvent e) { if (jSliderContainer.getSelfAdaptButton().isSelected()){ int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().selfAdaptUpdate(); - jSliderContainer.getShowVal().setValue(resolution); + jSliderContainer.getShowVal().setValue(resolution*HUND/ScreenResolution.getScreenResolution()); } } }; diff --git a/designer/src/com/fr/poly/PolyArea.java b/designer/src/com/fr/poly/PolyArea.java index 07a79edc53..c9589f69f1 100644 --- a/designer/src/com/fr/poly/PolyArea.java +++ b/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; } diff --git a/designer/src/com/fr/poly/PolyDesignUI.java b/designer/src/com/fr/poly/PolyDesignUI.java index e46a24310a..58ed225b85 100644 --- a/designer/src/com/fr/poly/PolyDesignUI.java +++ b/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,19 @@ public class PolyDesignUI extends ComponentUI { private static final double SCROLL_POINT = 50; private static final int SCROLL_DISTANCE = 15; - + private static final int CREATORWIDTH = 30; + private static final int CREATORGEIGHT = 19; + 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 +92,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,20 +111,27 @@ 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()); - if (creator.getEditor().isDragging()) { - creator.getEditor().paintAbsorptionline(g); - //如果与其他块重合了, 需要画出提示禁止重叠 - changeForbiddenWindowVisibility(creator); - //到边缘地带自动滚动 - scrollWhenCreatorAtCorner(creator); - }else{ - creator.getEditor().hideForbiddenWindow(); - } + if (creator instanceof ECBlockCreator){ + int x = (int) ((creator.getX()-CREATORWIDTH)*time)+CREATORWIDTH; + int y = (int) ((creator.getY()-CREATORGEIGHT)*time)+CREATORGEIGHT; + paintPositionLine(g, x, y, (int) (designer.getHorizontalValue()*time), (int) (designer.getVerticalValue()*time)); + }else { + int x = (int) (creator.getX()*time); + int y = (int) (creator.getY()*time); + paintPositionLine(g, x, y, (int) (designer.getHorizontalValue()*time), (int) (designer.getVerticalValue()*time)); + } + if (creator.getEditor().isDragging()) { + creator.getEditor().paintAbsorptionline(g); + //如果与其他块重合了, 需要画出提示禁止重叠 + changeForbiddenWindowVisibility(creator); + //到边缘地带自动滚动 + scrollWhenCreatorAtCorner(creator); + }else{ + 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 +144,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 +201,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 +221,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 +232,16 @@ public class PolyDesignUI extends ComponentUI { ArrayList dbcomponents = new ArrayList(); // 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); } diff --git a/designer/src/com/fr/poly/PolyDesigner.java b/designer/src/com/fr/poly/PolyDesigner.java index faa15a9463..e2a25aeb6d 100644 --- a/designer/src/com/fr/poly/PolyDesigner.java +++ b/designer/src/com/fr/poly/PolyDesigner.java @@ -3,14 +3,10 @@ */ 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.*; import java.awt.event.ActionEvent; import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; @@ -36,16 +32,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; @@ -75,6 +62,7 @@ import com.fr.report.block.Block; import com.fr.report.poly.PolyWorkSheet; import com.fr.report.poly.TemplateBlock; import com.fr.stable.ArrayUtils; +import com.fr.stable.CoreGraphHelper; import com.fr.stable.StringUtils; import com.fr.stable.unit.FU; import com.fr.stable.unit.OLDPIX; @@ -98,7 +86,7 @@ public class PolyDesigner extends ReportComponent clip_board = new ArrayList(); - // richer:鼠标滚轮每滚动一下,PolyDesignPane的尺寸就改变ROTATIONS这么多 private static final int ROTATIONS = 50; private JScrollBar verScrollBar; private JScrollBar horScrollBar; - private JComponent polyArea; + private PolyComponetsBar polyComponetsBar = new PolyComponetsBar(); private JComponent[] toolBarComponent = null; - private int resolution = ScreenResolution.getScreenResolution(); + private int resolution = (int) (ScreenResolution.getScreenResolution()* JSliderPane.getInstance().resolutionTimes); + private float time; public PolyDesigner(PolyWorkSheet report) { super(report); @@ -157,7 +145,7 @@ public class PolyDesigner extends ReportComponent extends JComponent i LayoutUtils.layoutContainer(this); } + public void setResolution(int resolution){ + this.resolution = resolution; + } + //默认大小, 报表块默认3列6行, 图表块默认330*240 public abstract UnitRectangle getDefaultBlockBounds(); diff --git a/designer/src/com/fr/poly/creator/BlockEditor.java b/designer/src/com/fr/poly/creator/BlockEditor.java index 2e058b0f49..070f3e3a02 100644 --- a/designer/src/com/fr/poly/creator/BlockEditor.java +++ b/designer/src/com/fr/poly/creator/BlockEditor.java @@ -50,7 +50,7 @@ public abstract class BlockEditor public BlockEditor(PolyDesigner designer, BlockCreator creator) { this.designer = designer; this.creator = creator; - + this.resolution = creator.resolution; this.initComponets(); this.addColumnRowListeners(); diff --git a/designer/src/com/fr/poly/creator/ChartBlockCreator.java b/designer/src/com/fr/poly/creator/ChartBlockCreator.java index ca8106ffae..93e25d21e0 100644 --- a/designer/src/com/fr/poly/creator/ChartBlockCreator.java +++ b/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 { 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 { super(block); } + public void setResolution(int resolution){ + this.resolution = resolution; + } + /** * 初始化 * @return 初始化的控件. @@ -65,6 +72,7 @@ public class ChartBlockCreator extends BlockCreator { } + /** * 检测按钮状态 * diff --git a/designer/src/com/fr/poly/creator/ChartBlockEditor.java b/designer/src/com/fr/poly/creator/ChartBlockEditor.java index 8b0d90542d..8996b58fba 100644 --- a/designer/src/com/fr/poly/creator/ChartBlockEditor.java +++ b/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 { @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(); diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index 309fac533d..121171b7a8 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/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> ex private long openTime = 0L; // 打开模板的时间点(包括新建模板) private TemplateInfoCollector tic = TemplateInfoCollector.getInstance(); private StringBuilder process = new StringBuilder(""); // 制作模板的过程 + private int resolution = ScreenResolution.getScreenResolution(); public JTemplate(T t, String defaultFileName) { this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true); @@ -144,6 +143,12 @@ public abstract class JTemplate> ex return undoState; } + public abstract void setJTemplateResolution(int resolution); + + public abstract int getJTemplateResolution(); + + ; + /** * 初始化权限细粒度撤销状态 */ diff --git a/designer_chart/src/com/fr/design/chart/gui/ChartComponent.java b/designer_chart/src/com/fr/design/chart/gui/ChartComponent.java index 5ce350450b..127f640d2d 100644 --- a/designer_chart/src/com/fr/design/chart/gui/ChartComponent.java +++ b/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; @@ -171,7 +172,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene g2d.setPaint(Color.white); g2d.fillRect(0, 0, this.getBounds().width, this.getBounds().height); g2d.setPaint(oldPaint); - + g2d.translate(ChartConstants.PREGAP4BOUNDS/2, ChartConstants.PREGAP4BOUNDS/2); if (needRefreshChartGlyph()) { @@ -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); } } diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index e6288dc2f7..2e6aefaeb1 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -104,6 +104,16 @@ public class JForm extends JTemplate implements BaseJForm { return processInfo; } + @Override + public void setJTemplateResolution(int resolution) { + + } + + @Override + public int getJTemplateResolution() { + return 0; + } + @Override protected boolean accept(Object o) { return !(o instanceof FloatElementsProvider); From 5985819f8e4075d08874e6b071eac96b0b4b93ef Mon Sep 17 00:00:00 2001 From: plough Date: Mon, 24 Jul 2017 10:06:11 +0800 Subject: [PATCH 08/18] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=88=97=E8=A1=A8=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/controlpane/UIControlPane.java | 42 ++ .../gui/controlpane/UIListControlPane.java | 14 +- .../UINameableListCellRenderer.java | 23 +- .../com/fr/design/gui/ilist/UINameEdList.java | 398 ++++++++++++++++++ 4 files changed, 466 insertions(+), 11 deletions(-) create mode 100644 designer_base/src/com/fr/design/gui/ilist/UINameEdList.java diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java index f67512d92f..b21b740f5a 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java @@ -6,6 +6,7 @@ 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; @@ -28,6 +29,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH private ToolBarDef toolbarDef; private UIToolbar toolBar; + protected PopupEditPane popupEditPane; // peter:这是整体的一个cardLayout Pane protected CardLayout cardLayout; @@ -101,6 +103,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH 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())); @@ -229,4 +232,43 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH toolBar.repaint(); this.repaint(); } + + // 点击"编辑"按钮,弹出面板 + protected class PopupEditPane extends JPopupMenu { + private JComponent contentPane; + // private PopupToolPane popupToolPane; + private int fixedHeight; + + PopupEditPane(JComponent pane) { + contentPane = pane; + this.setLayout(new BorderLayout()); + this.add(contentPane, BorderLayout.CENTER); + this.setOpaque(false); +// 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(); + } + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java index c36a7902c2..878668f0d0 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java @@ -10,7 +10,7 @@ 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.icontainer.UIScrollPane; -import com.fr.design.gui.ilist.JNameEdList; +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; @@ -48,7 +48,7 @@ import java.util.Comparator; public abstract class UIListControlPane extends UIControlPane { public static final String LIST_NAME = "UIControl_List"; - protected JNameEdList nameableList; + protected UINameEdList nameableList; protected int editingIndex; protected String selectedName; private boolean isNameRepeated = false; @@ -96,8 +96,8 @@ public abstract class UIListControlPane extends UIControlPane { }); } - public JNameEdList createJNameList() { - JNameEdList nameEdList = new JNameEdList(new DefaultListModel()) { + public UINameEdList createJNameList() { + UINameEdList nameEdList = new UINameEdList(new DefaultListModel()) { @Override protected void doAfterLostFocus() { UIListControlPane.this.updateControlUpdatePane(); @@ -216,7 +216,7 @@ public abstract class UIListControlPane extends UIControlPane { } /** - * 根据name,选中JNameEdList中的item + * 根据name,选中UINameEdList中的item */ public void setSelectedName(String name) { DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); @@ -277,7 +277,7 @@ public abstract class UIListControlPane extends UIControlPane { * @param index 序号 */ public void addNameable(Nameable nameable, int index) { - JNameEdList nameEdList = UIListControlPane.this.nameableList; + UINameEdList nameEdList = UIListControlPane.this.nameableList; DefaultListModel model = (DefaultListModel) nameEdList.getModel(); ListModelElement el = new ListModelElement(nameable); @@ -631,7 +631,7 @@ public abstract class UIListControlPane extends UIControlPane { } /* - * JNameEdList的鼠标事件 + * UINameEdList的鼠标事件 */ private MouseListener listMouseListener = new MouseAdapter() { @Override diff --git a/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java b/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java index df672e8a1d..e8844d3856 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java @@ -5,6 +5,7 @@ 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; @@ -12,6 +13,8 @@ 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 @@ -23,8 +26,8 @@ public class UINameableListCellRenderer extends 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); protected static Border noFocusBorder = DEFAULT_NO_FOCUS_BORDER; - private static final int BUTTON_WIDTH = 40; - private UIButton editButton; + private static final int BUTTON_WIDTH = 20; + private UILabel editButton; // "编辑按钮",实际上是一个 UILabel,由列表项(UIListControlPane)统一处理点击事件 private UILabel label; private UIListControlPane listControlPane; @@ -38,12 +41,19 @@ public class UINameableListCellRenderer extends } private void initComponents() { - editButton = new UIButton("edit") { + editButton = new UILabel() { public Dimension getPreferredSize() { return new Dimension(BUTTON_WIDTH, BUTTON_WIDTH); } }; - editButton.set4LargeToolbarButton(); +// editButton.set4LargeToolbarButton(); + editButton.setIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); +// editButton.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// popupEditPane(); +// } +// }); label = new UILabel(); // label.setEditable(false); this.setLayout(new BorderLayout()); @@ -51,6 +61,11 @@ public class UINameableListCellRenderer extends this.add(label, BorderLayout.CENTER); } + private void popupEditPane() { + GUICoreUtils.showPopupMenu(listControlPane.popupEditPane, editButton, + - listControlPane.popupEditPane.getPreferredSize().width, 0); + } + private Border getNoFocusBorder() { Border border = DefaultLookup.getBorder(this, ui, "List.cellNoFocusBorder"); if (System.getSecurityManager() != null) { diff --git a/designer_base/src/com/fr/design/gui/ilist/UINameEdList.java b/designer_base/src/com/fr/design/gui/ilist/UINameEdList.java new file mode 100644 index 0000000000..73ba2bf82c --- /dev/null +++ b/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 = 20; + 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 ll = new ArrayList(); + + 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; + } + } + +} \ No newline at end of file From 05451d24a6422e6600dd2333774e0a44fecd064d Mon Sep 17 00:00:00 2001 From: plough Date: Mon, 24 Jul 2017 10:52:44 +0800 Subject: [PATCH 09/18] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E5=BC=B9=E5=87=BA=E7=BC=96=E8=BE=91=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/controlpane/UIControlPane.java | 5 ++++- .../fr/design/gui/controlpane/UIListControlPane.java | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java index b21b740f5a..4de5f5d86b 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java @@ -236,14 +236,17 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH // 点击"编辑"按钮,弹出面板 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; +// 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(); } diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java index 878668f0d0..a6131b3ed5 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java @@ -47,6 +47,7 @@ import java.util.Comparator; public abstract class UIListControlPane extends UIControlPane { public static final String LIST_NAME = "UIControl_List"; + private static final int EDIT_RANGE = 20; // 编辑按钮的x坐标范围 protected UINameEdList nameableList; protected int editingIndex; @@ -356,6 +357,11 @@ public abstract class UIListControlPane extends UIControlPane { } } + private void popupEditPane() { + GUICoreUtils.showPopupMenu(popupEditPane, this, + - popupEditPane.getPreferredSize().width, nameableList.getSelectedIndex() * EDIT_RANGE); + } + /** * 增加项的UpdateAction */ @@ -638,11 +644,14 @@ public abstract class UIListControlPane extends UIControlPane { public void mouseReleased(MouseEvent evt) { nameableList.stopEditing(); if (evt.getClickCount() >= 2 - && SwingUtilities.isLeftMouseButton(evt)) { + && 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) { + popupEditPane(); } + // peter:处理右键的弹出菜单 if (!SwingUtilities.isRightMouseButton(evt)) { return; From 18c5fc394181f4604cd3f202e237988f7f898f55 Mon Sep 17 00:00:00 2001 From: plough Date: Mon, 24 Jul 2017 15:08:05 +0800 Subject: [PATCH 10/18] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=3D=E3=80=8B=E5=AE=8C=E5=96=84UI=E7=BB=86?= =?UTF-8?q?=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/controlpane/UIControlPane.java | 11 +++++- .../gui/controlpane/UIListControlPane.java | 24 +++++++++++- .../UINameableListCellRenderer.java | 37 ++++++++++--------- .../com/fr/design/gui/ilist/UINameEdList.java | 2 +- 4 files changed, 52 insertions(+), 22 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java index 4de5f5d86b..8878cd43a8 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java @@ -110,6 +110,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH // mainSplitPane.setOneTouchExpandable(true); this.add(getLeftPane(), BorderLayout.CENTER); + this.setBorder(BorderFactory.createEmptyBorder(0, 10, 12, 10)); // mainSplitPane.setDividerLocation(getLeftPreferredSize()); this.checkButtonEnabled(); } @@ -134,14 +135,21 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH toolbarDef.addShortCut(sj.getShortCut()); } toolBar = ToolBarDef.createJToolBar(); +// toolBar.setLayout(new FlowLayout(FlowLayout.LEFT)); toolbarDef.updateToolBar(toolBar); - leftContentPane.add(toolBar, BorderLayout.NORTH); + // 封装一层,加边框 + 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 }; @@ -150,6 +158,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH 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; diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java index a6131b3ed5..c082f66983 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java @@ -9,6 +9,7 @@ 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; @@ -47,7 +48,7 @@ import java.util.Comparator; public abstract class UIListControlPane extends UIControlPane { public static final String LIST_NAME = "UIControl_List"; - private static final int EDIT_RANGE = 20; // 编辑按钮的x坐标范围 + private static final int EDIT_RANGE = 25; // 编辑按钮的x坐标范围 protected UINameEdList nameableList; protected int editingIndex; @@ -358,8 +359,11 @@ public abstract class UIListControlPane extends UIControlPane { } private void popupEditPane() { + if (editingIndex < 0) { + return; + } GUICoreUtils.showPopupMenu(popupEditPane, this, - - popupEditPane.getPreferredSize().width, nameableList.getSelectedIndex() * EDIT_RANGE); + - popupEditPane.getPreferredSize().width, editingIndex * EDIT_RANGE); } /** @@ -394,6 +398,21 @@ public abstract class UIListControlPane extends UIControlPane { 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())) { @@ -649,6 +668,7 @@ public abstract class UIListControlPane extends UIControlPane { selectedName = nameableList.getNameAt(editingIndex); nameableList.editItemAt(nameableList.getSelectedIndex()); } else if (SwingUtilities.isLeftMouseButton(evt) && evt.getX() <= EDIT_RANGE) { + editingIndex = nameableList.getSelectedIndex(); popupEditPane(); } diff --git a/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java b/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java index e8844d3856..e56b038074 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java @@ -25,8 +25,9 @@ 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 = 20; + private static final int BUTTON_WIDTH = 25; private UILabel editButton; // "编辑按钮",实际上是一个 UILabel,由列表项(UIListControlPane)统一处理点击事件 private UILabel label; private UIListControlPane listControlPane; @@ -48,6 +49,8 @@ public class UINameableListCellRenderer extends }; // 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) { @@ -55,30 +58,28 @@ public class UINameableListCellRenderer extends // } // }); 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 void popupEditPane() { - GUICoreUtils.showPopupMenu(listControlPane.popupEditPane, editButton, - - listControlPane.popupEditPane.getPreferredSize().width, 0); - } - private Border getNoFocusBorder() { - 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; - } +// 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) { diff --git a/designer_base/src/com/fr/design/gui/ilist/UINameEdList.java b/designer_base/src/com/fr/design/gui/ilist/UINameEdList.java index 73ba2bf82c..823c95d6e4 100644 --- a/designer_base/src/com/fr/design/gui/ilist/UINameEdList.java +++ b/designer_base/src/com/fr/design/gui/ilist/UINameEdList.java @@ -24,7 +24,7 @@ import java.util.Vector; */ public class UINameEdList extends UIList implements CellEditorListener { private static final int TEST_LIST_LENTH = 20; - private static final int BUTTON_WIDTH = 20; + private static final int BUTTON_WIDTH = 25; private boolean editable = true; // kunsnat: 是否强制ListName是数字 (int型) From f59ff6bb4064135210d27be5c868eebe14eef08c Mon Sep 17 00:00:00 2001 From: MoMeak Date: Mon, 24 Jul 2017 15:17:15 +0800 Subject: [PATCH 11/18] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20=E7=BC=A9=E6=94=BE=E6=9D=A1?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/ElementCasePane.java | 12 ++++- .../com/fr/design/mainframe/JWorkBook.java | 1 + .../form/FormReportComponentComposite.java | 54 ++++++++++++++++--- .../com/fr/design/mainframe/JTemplate.java | 2 +- .../src/com/fr/design/mainframe/FormArea.java | 29 +++++----- .../com/fr/design/mainframe/FormDesigner.java | 11 ++++ .../fr/design/mainframe/FormDesignerUI.java | 26 ++++++--- .../src/com/fr/design/mainframe/JForm.java | 49 ++++++++++++++++- 8 files changed, 155 insertions(+), 29 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/ElementCasePane.java b/designer/src/com/fr/design/mainframe/ElementCasePane.java index 17dfa8442d..6682a6fa58 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePane.java +++ b/designer/src/com/fr/design/mainframe/ElementCasePane.java @@ -209,7 +209,9 @@ public abstract class ElementCasePane extends Tar this.setLayout(new RGridLayout()); //todo 直接修改分辨率 - this.resolution = ScreenResolution.getScreenResolution(); + if (this.resolution == 0){ + this.resolution = ScreenResolution.getScreenResolution(); + } this.initGridComponent(); @@ -344,6 +346,14 @@ public abstract class ElementCasePane extends Tar } + public void setResolution(int resolution){ + this.resolution = resolution; + } + + public int getResolution(){ + return this.resolution; + } + /** * 所有的操作都必须在可见范围内,否则不做任何操作 * diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index 8251368849..1fa6ee8d52 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -345,6 +345,7 @@ public class JWorkBook extends JTemplate { //更新resolution this.resolution = resolution; if (reportComposite.centerCardPane.editingComponet.elementCasePane != null){ + reportComposite.centerCardPane.editingComponet.elementCasePane.setResolution(resolution); reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().getGridMouseAdapter().setResolution(resolution); reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().setResolution(resolution); //更新Grid diff --git a/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java b/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java index 11bfbe476d..d9ad0f35f3 100644 --- a/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java @@ -1,29 +1,41 @@ package com.fr.design.mainframe.form; +import com.fr.base.ScreenResolution; 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.JForm; +import com.fr.design.mainframe.JSliderPane; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseProvider; 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.ItemEvent; +import java.awt.event.ItemListener; /** * 整个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; public FormReportComponentComposite(BaseJForm jform, FormElementCaseDesigner elementCaseDesign, FormElementCaseContainerProvider ecContainer) { @@ -33,10 +45,33 @@ 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); elementCaseDesigner.addTargetModifiedListener(this); } + ChangeListener showValSpinnerChangeListener = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + double value = (int) ((UIBasicSpinner)e.getSource()).getValue(); + value = value>MAX ? MAX : value; + value = value targetModifiedList = new java.util.ArrayList(); /** @@ -62,13 +97,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; } /** diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index 121171b7a8..95614b2124 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -80,7 +80,7 @@ public abstract class JTemplate> ex private long openTime = 0L; // 打开模板的时间点(包括新建模板) private TemplateInfoCollector tic = TemplateInfoCollector.getInstance(); private StringBuilder process = new StringBuilder(""); // 制作模板的过程 - private int resolution = ScreenResolution.getScreenResolution(); + public int resolution = ScreenResolution.getScreenResolution(); public JTemplate(T t, String defaultFileName) { this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true); diff --git a/designer_form/src/com/fr/design/mainframe/FormArea.java b/designer_form/src/com/fr/design/mainframe/FormArea.java index b7853183e1..1203bdf0de 100644 --- a/designer_form/src/com/fr/design/mainframe/FormArea.java +++ b/designer_form/src/com/fr/design/mainframe/FormArea.java @@ -23,6 +23,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; @@ -64,12 +65,12 @@ 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; public FormScrollBar getHorScrollBar() { return horScrollBar; @@ -123,8 +124,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[][]{ @@ -160,14 +161,18 @@ public class FormArea extends JComponent implements ScrollRulerComponent { ChangeListener showValSpinnerChangeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - double value = (int) ((UIBasicSpinner)e.getSource()).getValue(); - value = value>SHOWVALMAX ? SHOWVALMAX : value; - value = valueSHOWVALMAX ? SHOWVALMAX : value; + value = value 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
implements TreeSelection } } + + public void setResolution(int resolution){ + this.resolution = resolution; + } + + public int getResolution(){ + return this.resolution; + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java b/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java index 259e1b65ef..2cc0cabdfc 100644 --- a/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java +++ b/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(); diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index 2e6aefaeb1..7cb1e0e01f 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -1,10 +1,13 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; +import com.fr.base.DynamicUnitList; +import com.fr.base.ScreenResolution; import com.fr.design.DesignState; import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.actions.file.WebPreviewUtils; import com.fr.design.cell.FloatElementsProvider; +import com.fr.design.cell.bar.DynamicScrollBar; import com.fr.design.constants.UIConstants; import com.fr.design.designer.beans.actions.CopyAction; import com.fr.design.designer.beans.actions.CutAction; @@ -26,6 +29,8 @@ import com.fr.design.mainframe.actions.FormMobileAttrAction; import com.fr.design.mainframe.actions.TemplateParameterAction; import com.fr.design.mainframe.form.FormECCompositeProvider; import com.fr.design.mainframe.form.FormECDesignerProvider; +import com.fr.design.mainframe.form.FormElementCasePaneDelegate; +import com.fr.design.mainframe.form.FormReportComponentComposite; import com.fr.design.mainframe.templateinfo.JFormProcessInfo; import com.fr.design.mainframe.templateinfo.TemplateProcessInfo; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; @@ -47,6 +52,9 @@ import com.fr.form.ui.container.WLayout; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; +import com.fr.grid.Grid; +import com.fr.grid.GridUtils; +import com.fr.report.ReportHelper; import com.fr.stable.ArrayUtils; import com.fr.stable.Constants; import com.fr.stable.bridge.StableFactory; @@ -256,7 +264,25 @@ public class JForm extends JTemplate implements BaseJForm { @Override public void setScale(int resolution) { - + this.resolution = resolution; + ElementCasePane elementCasePane = ((FormReportComponentComposite)reportComposite).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(); } @Override @@ -266,7 +292,26 @@ public class JForm extends JTemplate implements BaseJForm { @Override public int selfAdaptUpdate() { - return 0; + if (resolution == 0){ + resolution = ScreenResolution.getScreenResolution(); + } + ElementCasePane elementCasePane = ((FormReportComponentComposite)reportComposite).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 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()); } /** From 56d93a11d5abba348d04a6aad37b8ae94909ebd5 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Mon, 24 Jul 2017 15:21:13 +0800 Subject: [PATCH 12/18] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20=E7=BC=A9=E6=94=BE=E6=9D=A1?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/JFormSliderPane.java | 433 ++++++++++++++++++ 1 file changed, 433 insertions(+) create mode 100644 designer_base/src/com/fr/design/mainframe/JFormSliderPane.java diff --git a/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java b/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java new file mode 100644 index 0000000000..dd6fdb756d --- /dev/null +++ b/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java @@ -0,0 +1,433 @@ +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 javax.swing.plaf.basic.BasicSliderUI; +import java.awt.*; +import java.awt.event.*; +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 ONEEIGHT = 18; + private static final int FONTSIZE = 14; + private static final int SPINNERWIDTH= 45; + private static final int SPINNERHEIGHT = 20; + private static final int TWOFIVE = 25; + private static final int FOURTEN = 40; + private static final int HALFHUNDRED = 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 = 220; + private static final int SHOWVALBUTTONWIDTH = 70; + private static final int SHOWVALBUTTONHEIGHTH = 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,HALFHUNDRED); + slider.setUI(new JSliderPaneUI(slider)); + slider.addChangeListener(listener); + + showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, TEN, FOURHUNDRED, 1)); + showValSpinner.setEnabled(true); + showValSpinner.addChangeListener(showValSpinnerChangeListener); + showValSpinner.setPreferredSize(new Dimension(SPINNERWIDTH, SPINNERHEIGHT)); + //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(SHOWVALBUTTONWIDTH,SHOWVALBUTTONHEIGHTH)); + 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); + } + + 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, FONTSIZE)); + 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); + 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+TWOHUNDRED)/SIX); + }else if (showValue = TEN ){ + showValue = newDownVal; + showValSpinner.setValue(newDownVal); + }else { + showValue = newDownVal; + showValSpinner.setValue(TEN); + } + } + if(e.getActionCommand().equals("more")){ + int newUpVal = showValue + TEN; + if (newUpVal <= FOURHUNDRED ){ + showValue = newUpVal; + showValSpinner.setValue(newUpVal); + }else { + showValue = newUpVal; + showValSpinner.setValue(FOURHUNDRED); + } + } + 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); + } + } + + + 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, - DIALOGWIDTH + upButton.getWidth() + SHOWVALBUTTONWIDTH , -DIALOGHEIGHT); + } + }else { + if (upButtonX == 0) { + upButtonX = btnCoords.x; + GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +SHOWVALBUTTONWIDTH, -DIALOGHEIGHT); + } else { + GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +SHOWVALBUTTONWIDTH, -DIALOGHEIGHT); + } + } + } + + 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 JFromSliderPaneUI extends BasicSliderUI { +// +// private static final int VERTICAL_WIDTH = 11; +// private static final int VERTICAL_HEIGHT = 16; +// private static final int FOUR = 4; +// private static final int FIVE = 5; +// private static final int SIX = 6; +// +// public JFromSliderPaneUI(UISlider b) { +// super(b); +// } +// +// /** */ +// /** +// * 绘制指示物 +// */ +// +// public Dimension getThumbSize() { +// Dimension size = new Dimension(); +// +// if ( slider.getOrientation() == JSlider.VERTICAL ) { +// size.width = VERTICAL_WIDTH; +// size.height = VERTICAL_HEIGHT; +// } +// else { +// size.width = VERTICAL_WIDTH; +// size.height = VERTICAL_HEIGHT; +// } +// +// return size; +// } +// +// public void paintThumb(Graphics g) { +// Rectangle knobBounds = thumbRect; +// int w = knobBounds.width; +// int h = knobBounds.height; +// +// g.translate(knobBounds.x, knobBounds.y); +// if ( slider.isEnabled() ) { +// g.setColor(slider.getBackground()); +// } +// else { +// g.setColor(slider.getBackground().darker()); +// } +// g.setColor(Color.darkGray); +// g.fillRect(0, 1, w-SIX, h+1); +// } +// +// /** */ +// /** +// * 绘制刻度轨迹 +// */ +// public void paintTrack(Graphics g) { +// int cy, cw; +// Rectangle trackBounds = trackRect; +// if (slider.getOrientation() == UISlider.HORIZONTAL) { +// Graphics2D g2 = (Graphics2D) g; +// 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); +// } else { +// super.paintTrack(g); +// } +// } +// +//} +// +class FormPopupPane 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 = 220; + private static final int UPLABELWIDTH = 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(UPLABELWIDTH,UPLABELHEIGHT)); + 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(DIALOGWIDTH, DIALOGHEIGHT)); + this.setOpaque(false); + } + + +} \ No newline at end of file From 2b45c73474cb2abb7caefcdc2a6b07b64042855e Mon Sep 17 00:00:00 2001 From: MoMeak Date: Mon, 24 Jul 2017 15:58:26 +0800 Subject: [PATCH 13/18] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20=E7=BC=A9=E6=94=BE=E6=9D=A1?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JWorkBook.java | 60 ++++++++++--------- .../fr/design/mainframe/ReportComponent.java | 4 -- .../mainframe/ReportComponentCardPane.java | 6 +- .../mainframe/ReportComponentComposite.java | 4 +- .../mainframe/ReportHyperlinkGroupPane.java | 5 -- .../form/FormReportComponentComposite.java | 6 +- .../com/fr/design/present/BarCodePane.java | 10 ---- designer/src/com/fr/poly/PolyDesignUI.java | 11 +--- .../src/com/fr/poly/creator/BlockCreator.java | 5 ++ .../fr/poly/creator/ChartBlockCreator.java | 9 +++ .../com/fr/poly/creator/ECBlockCreator.java | 13 ++++ 11 files changed, 71 insertions(+), 62 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index 5ab98eef79..e99c24a948 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -345,29 +345,31 @@ public class JWorkBook extends JTemplate { public void setScale(int resolution) { //更新resolution this.resolution = resolution; - if (reportComposite.centerCardPane.editingComponet.elementCasePane != null){ - reportComposite.centerCardPane.editingComponet.elementCasePane.setResolution(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 - ((DynamicScrollBar)reportComposite.centerCardPane.editingComponet.elementCasePane.getVerticalScrollBar()).setDpi(resolution); - ((DynamicScrollBar)reportComposite.centerCardPane.editingComponet.elementCasePane.getHorizontalScrollBar()).setDpi(resolution); - 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 (reportComposite.centerCardPane.polyDezi != null){ - reportComposite.centerCardPane.polyDezi.setResolution(resolution); + if (polyDezi != null){ + polyDezi.setResolution(resolution); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setJTemplateResolution(resolution); - reportComposite.centerCardPane.polyDezi.updateUI(); + polyDezi.updateUI(); } // reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().setVerticalValue(10); @@ -375,27 +377,29 @@ public class JWorkBook extends JTemplate { } @Override public int selfAdaptUpdate(){ + PolyDesigner polyDezi = reportComposite.centerCardPane.getPolyDezi(); + ElementCasePane elementCasePane = reportComposite.centerCardPane.editingComponet.elementCasePane; if (resolution == 0){ resolution = ScreenResolution.getScreenResolution(); } - if (reportComposite.centerCardPane.polyDezi.getSelection() !=null){ - BlockCreator blockCreator =reportComposite.centerCardPane.polyDezi.getSelection(); + if (polyDezi.getSelection() !=null){ + BlockCreator blockCreator =polyDezi.getSelection(); double x = blockCreator.getEditorBounds().getX(); double y = blockCreator.getEditorBounds().getY(); - reportComposite.centerCardPane.polyDezi.setHorizontalValue((int) x); - reportComposite.centerCardPane.polyDezi.setVerticalValue((int) y); + polyDezi.setHorizontalValue((int) x); + polyDezi.setVerticalValue((int) y); double creatorHeight = blockCreator.getEditorBounds().height; double creatorWidth = blockCreator.getEditorBounds().width; - double areaHeight = reportComposite.centerCardPane.polyDezi.polyArea.getHeight(); - double areaWidth = reportComposite.centerCardPane.polyDezi.polyArea.getWidth(); + 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 * reportComposite.centerCardPane.polyDezi.getResolution()); + return (int) (time * polyDezi.getResolution()); - }else if (reportComposite.centerCardPane.editingComponet.elementCasePane != null) { - ElementCasePane reportPane = reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().getElementCasePane(); + }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(); @@ -405,12 +409,12 @@ public class JWorkBook extends JTemplate { if (columnLength == 0||rowLength == 0){ return resolution; } - double time =(columnExtent/columnLength)<(rowExtent/rowLength) ? (columnExtent/columnLength) : (rowExtent/rowLength); + double time = (columnExtent/columnLength) < (rowExtent/rowLength) ? (columnExtent/columnLength) : (rowExtent/rowLength); if (reportPane.isHorizontalScrollBarVisible()) { reportPane.getVerticalScrollBar().setValue(row); reportPane.getHorizontalScrollBar().setValue(column); } - return (int) (time * reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().getResolution()); + return (int) (time * elementCasePane.getGrid().getResolution()); }else { return resolution; } diff --git a/designer/src/com/fr/design/mainframe/ReportComponent.java b/designer/src/com/fr/design/mainframe/ReportComponent.java index 42342f24e7..6ca2685454 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponent.java +++ b/designer/src/com/fr/design/mainframe/ReportComponent.java @@ -27,13 +27,9 @@ import com.fr.design.selection.Selectedable; */ public abstract class ReportComponent extends TargetComponent implements Selectedable { protected E elementCasePane; -// protected P polyElementCasePane; public E getEditingElementCasePane() { return elementCasePane; } -// public P getEditingPolyElementCasePane() { -// return polyElementCasePane; -// } public ReportComponent(T t) { super(t); } diff --git a/designer/src/com/fr/design/mainframe/ReportComponentCardPane.java b/designer/src/com/fr/design/mainframe/ReportComponentCardPane.java index cc45cf5e90..f574892c92 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentCardPane.java +++ b/designer/src/com/fr/design/mainframe/ReportComponentCardPane.java @@ -25,7 +25,7 @@ public class ReportComponentCardPane extends JComponent implements TargetModifie private CardLayout cl; private WorkSheetDesigner sheetDezi; - protected PolyDesigner polyDezi; + private PolyDesigner polyDezi; public ReportComponentCardPane() { this.setLayout(cl = new CardLayout()); @@ -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(); diff --git a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java index 1b4fcdd1d2..15a4b32331 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java @@ -73,8 +73,8 @@ public class ReportComponentComposite extends JComponent { @Override public void stateChanged(ChangeEvent e) { double value = (int) ((UIBasicSpinner)e.getSource()).getValue(); - value = value>MAX ? MAX : value; - value = value MAX ? MAX : value; + value = value < MIN ? MIN : value; int resolution = (int) (ScreenResolution.getScreenResolution()*value/HUND); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution); } diff --git a/designer/src/com/fr/design/mainframe/ReportHyperlinkGroupPane.java b/designer/src/com/fr/design/mainframe/ReportHyperlinkGroupPane.java index 64c397da1b..d4f06ea4cd 100644 --- a/designer/src/com/fr/design/mainframe/ReportHyperlinkGroupPane.java +++ b/designer/src/com/fr/design/mainframe/ReportHyperlinkGroupPane.java @@ -27,11 +27,6 @@ public class ReportHyperlinkGroupPane extends HyperlinkGroupPane { } public void populate(ElementCasePane reportPane) { -// TemplateElementCase elementCase = ePane.getEditingElementCase(); -// if (elementCase == null) { -// return; -// } -// ePane.getSelection().populatePropertyPane(ePane); final TemplateElementCase report = reportPane.getEditingElementCase(); NameJavaScriptGroup nameHyperlinks = getNameJSGroup(reportPane, report); populate(nameHyperlinks); diff --git a/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java b/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java index d9ad0f35f3..67521bf3a3 100644 --- a/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java @@ -54,9 +54,9 @@ public class FormReportComponentComposite extends JComponent implements TargetMo @Override public void stateChanged(ChangeEvent e) { double value = (int) ((UIBasicSpinner)e.getSource()).getValue(); - value = value>MAX ? MAX : value; - value = value MAX ? MAX : value; + value = value < MIN ? MIN : value; + int resolution = (int) (ScreenResolution.getScreenResolution()*value/HUND); JForm jf = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution); } diff --git a/designer/src/com/fr/design/present/BarCodePane.java b/designer/src/com/fr/design/present/BarCodePane.java index 1d59bee6c7..27a42a7e98 100644 --- a/designer/src/com/fr/design/present/BarCodePane.java +++ b/designer/src/com/fr/design/present/BarCodePane.java @@ -69,16 +69,6 @@ public class BarCodePane extends FurtherBasicBeanPane { addlistener(); } - 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(new BarCodePane(),BorderLayout.CENTER); - GUICoreUtils.centerWindow(jf); - jf.setSize(270, 400); - jf.setVisible(true); - } private void initComponents() { barCodePreviewPane = new BarCodePreviewPane(); diff --git a/designer/src/com/fr/poly/PolyDesignUI.java b/designer/src/com/fr/poly/PolyDesignUI.java index 58ed225b85..bc5fb7af86 100644 --- a/designer/src/com/fr/poly/PolyDesignUI.java +++ b/designer/src/com/fr/poly/PolyDesignUI.java @@ -111,15 +111,8 @@ public class PolyDesignUI extends ComponentUI { BlockCreator creator = addedData.getAddedAt(i); // richer:如果当前这个组件正在编辑,那么他是完全被他的编辑器所遮挡的,不需要画出来 if (creator == designer.getSelection()) { - if (creator instanceof ECBlockCreator){ - int x = (int) ((creator.getX()-CREATORWIDTH)*time)+CREATORWIDTH; - int y = (int) ((creator.getY()-CREATORGEIGHT)*time)+CREATORGEIGHT; - paintPositionLine(g, x, y, (int) (designer.getHorizontalValue()*time), (int) (designer.getVerticalValue()*time)); - }else { - int x = (int) (creator.getX()*time); - int y = (int) (creator.getY()*time); - paintPositionLine(g, x, y, (int) (designer.getHorizontalValue()*time), (int) (designer.getVerticalValue()*time)); - } + paintPositionLine(g, creator.getX(time), creator.getY(time), + (int) (designer.getHorizontalValue()*time), (int) (designer.getVerticalValue()*time)); if (creator.getEditor().isDragging()) { creator.getEditor().paintAbsorptionline(g); //如果与其他块重合了, 需要画出提示禁止重叠 diff --git a/designer/src/com/fr/poly/creator/BlockCreator.java b/designer/src/com/fr/poly/creator/BlockCreator.java index 1719c42ebd..052e111a8e 100644 --- a/designer/src/com/fr/poly/creator/BlockCreator.java +++ b/designer/src/com/fr/poly/creator/BlockCreator.java @@ -89,6 +89,11 @@ public abstract class BlockCreator extends JComponent i public abstract BlockEditor getEditor(); + public abstract int getX(float time); + + public abstract int getY(float time); + + /** * 检测按钮状态 diff --git a/designer/src/com/fr/poly/creator/ChartBlockCreator.java b/designer/src/com/fr/poly/creator/ChartBlockCreator.java index 93e25d21e0..d713356c60 100644 --- a/designer/src/com/fr/poly/creator/ChartBlockCreator.java +++ b/designer/src/com/fr/poly/creator/ChartBlockCreator.java @@ -71,6 +71,15 @@ public class ChartBlockCreator extends BlockCreator { return editor; } + @Override + public int getX(float time) { + return (int) (this.getX() * time); + } + + @Override + public int getY(float time) { + return (int) (this.getY() * time); + } /** diff --git a/designer/src/com/fr/poly/creator/ECBlockCreator.java b/designer/src/com/fr/poly/creator/ECBlockCreator.java index c98c6f7082..860b65d72a 100644 --- a/designer/src/com/fr/poly/creator/ECBlockCreator.java +++ b/designer/src/com/fr/poly/creator/ECBlockCreator.java @@ -23,6 +23,9 @@ import com.fr.stable.unit.UnitRectangle; */ public class ECBlockCreator extends BlockCreator { private ECBlockEditor editor; + private static final int CREATORWIDTH = 30; + private static final int CREATORGEIGHT = 19; + public ECBlockCreator() { @@ -64,6 +67,16 @@ public class ECBlockCreator extends BlockCreator { return editor; } + @Override + public int getX(float time) { + return (int) ((this.getX() - CREATORWIDTH) * time) + CREATORWIDTH; + } + + @Override + public int getY(float time) { + return (int) ((this.getY() - CREATORGEIGHT) * time) + CREATORGEIGHT; + } + /** * 检测按钮状态 * From 3d10040e4ff8ae9d20e8608db37768b2005c8ab2 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Mon, 24 Jul 2017 16:07:48 +0800 Subject: [PATCH 14/18] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20=E7=BC=A9=E6=94=BE=E6=9D=A1?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/design/mainframe/JWorkBook.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index e99c24a948..159886966a 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -382,7 +382,7 @@ public class JWorkBook extends JTemplate { if (resolution == 0){ resolution = ScreenResolution.getScreenResolution(); } - if (polyDezi.getSelection() !=null){ + if (polyDezi != null && polyDezi.getSelection() != null){ BlockCreator blockCreator =polyDezi.getSelection(); double x = blockCreator.getEditorBounds().getX(); double y = blockCreator.getEditorBounds().getY(); From 48009352321da1ba75460dc65483baa00fb5637c Mon Sep 17 00:00:00 2001 From: MoMeak Date: Mon, 24 Jul 2017 18:15:03 +0800 Subject: [PATCH 15/18] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20=E7=BC=A9=E6=94=BE=E6=9D=A1?= =?UTF-8?q?=E9=83=A8=E5=88=86-=E5=A2=9E=E5=8A=A0=E9=94=AE=E7=9B=98?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/ElementCasePane.java | 2 + .../mainframe/ReportComponentComposite.java | 35 +++- .../form/FormReportComponentComposite.java | 100 ++++++++++-- .../fr/design/mainframe/JFormSliderPane.java | 149 +++++------------- .../com/fr/design/mainframe/JSliderPane.java | 97 ++++++------ .../src/com/fr/design/mainframe/FormArea.java | 38 ++++- .../src/com/fr/design/mainframe/JForm.java | 71 +++------ 7 files changed, 275 insertions(+), 217 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/ElementCasePane.java b/designer/src/com/fr/design/mainframe/ElementCasePane.java index 6682a6fa58..7683d8c3bc 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePane.java +++ b/designer/src/com/fr/design/mainframe/ElementCasePane.java @@ -242,6 +242,8 @@ public abstract class ElementCasePane extends Tar initFormatBrush(); } + + public int getMenuState() { return DesignState.WORK_SHEET; } diff --git a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java index 15a4b32331..6019d1c0df 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java @@ -1,8 +1,7 @@ package com.fr.design.mainframe; import java.awt.BorderLayout; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; +import java.awt.event.*; import java.util.ArrayList; import javax.swing.JComponent; @@ -51,6 +50,8 @@ public class ReportComponentComposite extends JComponent { private JSliderPane jSliderContainer; + private boolean isCtrl = false; + /** * Constructor with workbook.. @@ -67,8 +68,38 @@ public class ReportComponentComposite extends JComponent { this.add(createSouthControlPane(), BorderLayout.SOUTH); jSliderContainer.getShowVal().addChangeListener(showValSpinnerChangeListener); jSliderContainer.getSelfAdaptButton().addItemListener(selfAdaptButtonItemListener); + this.centerCardPane.editingComponet.elementCasePane.getGrid().addMouseWheelListener(showValSpinnerMouseWheelListener); + this.centerCardPane.editingComponet.elementCasePane.getGrid().addKeyListener(showValSpinnerKeyListener); } + KeyListener showValSpinnerKeyListener = new KeyListener() { + @Override + public void keyTyped(KeyEvent e) { + + } + @Override + public void keyPressed(KeyEvent e) { + if( e.getKeyText(e.getKeyCode()).toLowerCase().equals("ctrl")){ + 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) { diff --git a/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java b/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java index 67521bf3a3..9f4aebccc6 100644 --- a/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java @@ -1,26 +1,27 @@ 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.JForm; -import com.fr.design.mainframe.JSliderPane; +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.ItemEvent; -import java.awt.event.ItemListener; +import java.awt.event.*; /** * 整个FormElementCase编辑区域 包括滚动条、中间的grid或者聚合块、下面的sheetTab @@ -36,7 +37,7 @@ public class FormReportComponentComposite extends JComponent implements TargetMo private FormTabPane sheetNameTab; private JPanel hbarContainer; private JSliderPane jSliderContainer; - + private boolean isCtrl = false; public FormReportComponentComposite(BaseJForm jform, FormElementCaseDesigner elementCaseDesign, FormElementCaseContainerProvider ecContainer) { this.jForm = jform; @@ -47,9 +48,42 @@ public class FormReportComponentComposite extends JComponent implements TargetMo 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.getKeyText(e.getKeyCode()).toLowerCase().equals("ctrl")){ + 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) { @@ -57,8 +91,8 @@ public class FormReportComponentComposite extends JComponent implements TargetMo value = value > MAX ? MAX : value; value = value < MIN ? MIN : value; int resolution = (int) (ScreenResolution.getScreenResolution()*value/HUND); - JForm jf = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution); + setScale(resolution); +// HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution); } }; @@ -66,7 +100,7 @@ public class FormReportComponentComposite extends JComponent implements TargetMo @Override public void itemStateChanged(ItemEvent e) { if (jSliderContainer.getSelfAdaptButton().isSelected()){ - int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().selfAdaptUpdate(); + int resolution = selfAdaptUpdate(); jSliderContainer.getShowVal().setValue(resolution*HUND/ScreenResolution.getScreenResolution()); } } @@ -74,6 +108,52 @@ public class FormReportComponentComposite extends JComponent implements TargetMo private java.util.List targetModifiedList = new java.util.ArrayList(); + 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 目标改变事件 diff --git a/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java b/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java index dd6fdb756d..92b3fd6479 100644 --- a/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java +++ b/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java @@ -29,21 +29,19 @@ 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 ONEEIGHT = 18; - private static final int FONTSIZE = 14; - private static final int SPINNERWIDTH= 45; - private static final int SPINNERHEIGHT = 20; - private static final int TWOFIVE = 25; - 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 = 220; - private static final int SHOWVALBUTTONWIDTH = 70; - private static final int SHOWVALBUTTONHEIGHTH = 25; + 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; @@ -71,14 +69,14 @@ public class JFormSliderPane extends JPanel { public JFormSliderPane() { 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); - showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, TEN, FOURHUNDRED, 1)); + showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, TEN, FOUR_HUNDRED, 1)); showValSpinner.setEnabled(true); showValSpinner.addChangeListener(showValSpinnerChangeListener); - showValSpinner.setPreferredSize(new Dimension(SPINNERWIDTH, SPINNERHEIGHT)); + showValSpinner.setPreferredSize(new Dimension(SPINNER_WIDTH, SPINNER_HEIGHT)); //MoMeak:控制只能输入10-400,但是用起来感觉不舒服,先注释掉吧 // JSpinner.NumberEditor editor = new JSpinner.NumberEditor(showValSpinner, "0"); // showValSpinner.setEditor(editor); @@ -96,7 +94,7 @@ public class JFormSliderPane extends JPanel { showValButton = new UIButton(showValSpinner.getValue()+"%"); showValButton.setBorderPainted(false); - showValButton.setPreferredSize(new Dimension(SHOWVALBUTTONWIDTH,SHOWVALBUTTONHEIGHTH)); + showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH,SHOWVALBUTTON_HEIGHTH)); showValButton.addActionListener(showValButtonActionListener); initUIRadioButton(); @@ -107,7 +105,7 @@ public class JFormSliderPane extends JPanel { panel.add(upButton); panel.add(showValButton); this.add(panel,BorderLayout.NORTH); - this.setBounds(0,0,THREEHUNDRED,ONEEIGHT); + this.setBounds(0,0,THREE_HUNDRED,ONE_EIGHT); } public static final JFormSliderPane getInstance() { @@ -166,7 +164,7 @@ public class JFormSliderPane extends JPanel { JPanel spinnerPanel = new JPanel(new FlowLayout()); spinnerPanel.add(showValSpinner); UILabel percent = new UILabel("%"); - percent.setFont(new Font("Dialog", Font.PLAIN, FONTSIZE)); + percent.setFont(new Font("Dialog", Font.PLAIN, FONT_SIZE)); spinnerPanel.add(percent); return spinnerPanel; } @@ -184,6 +182,14 @@ public class JFormSliderPane extends JPanel { 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); } @@ -224,11 +230,11 @@ public class JFormSliderPane extends JPanel { private void refreshSlider(int val){ showValue = val; if (showValue >HUNDRED){ - slider.setValue((int)(showValue+TWOHUNDRED)/SIX); + slider.setValue((int)(showValue+TWO_HUNDRED)/SIX); }else if (showValue FOUR_HUNDRED){ + showValSpinner.setValue(FOUR_HUNDRED); + val = FOUR_HUNDRED; + } + if (val < TEN){ + showValSpinner.setValue(TEN); + val = TEN; + } refreshSlider(val); refreshBottun(val); } @@ -225,11 +229,11 @@ public class JSliderPane extends JPanel { private void refreshSlider(int val){ showValue = val; if (showValue >HUNDRED){ - slider.setValue((int)(showValue+TWOHUNDRED)/SIX); + slider.setValue((int)(showValue+TWO_HUNDRED)/SIX); }else if (showValue implements BaseJForm { return processInfo; } + public FormECCompositeProvider getReportComposite(){ + return this.reportComposite; + } + @Override public void setJTemplateResolution(int resolution) { @@ -264,25 +260,25 @@ public class JForm extends JTemplate implements BaseJForm { @Override public void setScale(int resolution) { - this.resolution = resolution; - ElementCasePane elementCasePane = ((FormReportComponentComposite)reportComposite).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(); +// this.resolution = resolution; +// ElementCasePane elementCasePane = ((FormReportComponentComposite)reportComposite).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(); } @Override @@ -292,26 +288,7 @@ public class JForm extends JTemplate implements BaseJForm { @Override public int selfAdaptUpdate() { - if (resolution == 0){ - resolution = ScreenResolution.getScreenResolution(); - } - ElementCasePane elementCasePane = ((FormReportComponentComposite)reportComposite).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 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()); + return 0; } /** From 8ad699c1bab852f5aeaea5f8713f8e5a4c5ed669 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Mon, 24 Jul 2017 19:32:49 +0800 Subject: [PATCH 16/18] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20=E4=BF=AE=E6=94=B9=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=B4=A8=E9=87=8F=EF=BC=8C=E5=8A=A0=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E6=96=B9=E6=B3=95=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JWorkBook.java | 2 -- .../mainframe/ReportComponentComposite.java | 2 +- .../form/FormReportComponentComposite.java | 2 +- designer/src/com/fr/poly/PolyDesignUI.java | 2 -- .../com/fr/poly/creator/ECBlockCreator.java | 8 ++++---- .../com/fr/design/mainframe/JTemplate.java | 10 +++++++++- .../src/com/fr/design/mainframe/FormArea.java | 2 +- .../src/com/fr/design/mainframe/JForm.java | 19 ------------------- 8 files changed, 16 insertions(+), 31 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index 159886966a..de214fb6dc 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -371,8 +371,6 @@ public class JWorkBook extends JTemplate { HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setJTemplateResolution(resolution); polyDezi.updateUI(); } -// reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().setVerticalValue(10); - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified(); } @Override diff --git a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java index 6019d1c0df..431a2ae5d9 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java @@ -79,7 +79,7 @@ public class ReportComponentComposite extends JComponent { } @Override public void keyPressed(KeyEvent e) { - if( e.getKeyText(e.getKeyCode()).toLowerCase().equals("ctrl")){ + if( e.isControlDown()){ isCtrl = true ; } } diff --git a/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java b/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java index 9f4aebccc6..b6173c6d80 100644 --- a/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java @@ -62,7 +62,7 @@ public class FormReportComponentComposite extends JComponent implements TargetMo } @Override public void keyPressed(KeyEvent e) { - if( e.getKeyText(e.getKeyCode()).toLowerCase().equals("ctrl")){ + if( e.isControlDown()){ isCtrl = true ; } } diff --git a/designer/src/com/fr/poly/PolyDesignUI.java b/designer/src/com/fr/poly/PolyDesignUI.java index bc5fb7af86..0eaf7c139e 100644 --- a/designer/src/com/fr/poly/PolyDesignUI.java +++ b/designer/src/com/fr/poly/PolyDesignUI.java @@ -47,8 +47,6 @@ public class PolyDesignUI extends ComponentUI { private static final double SCROLL_POINT = 50; private static final int SCROLL_DISTANCE = 15; - private static final int CREATORWIDTH = 30; - private static final int CREATORGEIGHT = 19; private static final int TEN = 10; private static final int HHUNDRED = 100; private PolyDesigner designer; diff --git a/designer/src/com/fr/poly/creator/ECBlockCreator.java b/designer/src/com/fr/poly/creator/ECBlockCreator.java index 860b65d72a..92313115e4 100644 --- a/designer/src/com/fr/poly/creator/ECBlockCreator.java +++ b/designer/src/com/fr/poly/creator/ECBlockCreator.java @@ -23,8 +23,8 @@ import com.fr.stable.unit.UnitRectangle; */ public class ECBlockCreator extends BlockCreator { private ECBlockEditor editor; - private static final int CREATORWIDTH = 30; - private static final int CREATORGEIGHT = 19; + private static final int CREATOR_WIDTH = 30; + private static final int CREATOR_HEIGHT = 19; public ECBlockCreator() { @@ -69,12 +69,12 @@ public class ECBlockCreator extends BlockCreator { @Override public int getX(float time) { - return (int) ((this.getX() - CREATORWIDTH) * time) + CREATORWIDTH; + return (int) ((this.getX() - CREATOR_WIDTH) * time) + CREATOR_WIDTH; } @Override public int getY(float time) { - return (int) ((this.getY() - CREATORGEIGHT) * time) + CREATORGEIGHT; + return (int) ((this.getY() - CREATOR_HEIGHT) * time) + CREATOR_HEIGHT; } /** diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index 2d8f42aad9..8f64ce9718 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -143,11 +143,13 @@ public abstract class JTemplate> ex return undoState; } + /** + * set/get 模板屏幕分辨率 + */ public abstract void setJTemplateResolution(int resolution); public abstract int getJTemplateResolution(); - ; /** * 初始化权限细粒度撤销状态 @@ -218,10 +220,16 @@ public abstract class JTemplate> ex */ public abstract void removeParameterPaneSelection(); + /** + * 缩放参数 + */ public abstract void setScale(int resolution); public abstract int getScale(); + /** + * 缩放参数自适应 + */ public abstract int selfAdaptUpdate(); protected abstract DesignModelAdapter createDesignModel(); diff --git a/designer_form/src/com/fr/design/mainframe/FormArea.java b/designer_form/src/com/fr/design/mainframe/FormArea.java index abab2469e4..6c59130df6 100644 --- a/designer_form/src/com/fr/design/mainframe/FormArea.java +++ b/designer_form/src/com/fr/design/mainframe/FormArea.java @@ -114,7 +114,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { } @Override public void keyPressed(KeyEvent e) { - if( e.getKeyText(e.getKeyCode()).toLowerCase().equals("ctrl")){ + if( e.isControlDown()){ isCtrl = true ; } } diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index 7ded93c6ee..7a3ca7ac4b 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -260,25 +260,6 @@ public class JForm extends JTemplate implements BaseJForm { @Override public void setScale(int resolution) { -// this.resolution = resolution; -// ElementCasePane elementCasePane = ((FormReportComponentComposite)reportComposite).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(); } @Override From 616c69a90c7713a74e1aad4aa69a7325a01648f5 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Tue, 25 Jul 2017 10:57:11 +0800 Subject: [PATCH 17/18] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20=E8=81=9A=E5=90=88=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E7=BC=A9=E6=94=BE=E6=9D=A1=E5=BF=AB=E6=8D=B7=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JWorkBook.java | 4 +- .../mainframe/ReportComponentComposite.java | 18 ++++---- designer/src/com/fr/poly/PolyDesigner.java | 46 ++++++++++++++++--- 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index de214fb6dc..b25b8f5faa 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -86,7 +86,7 @@ public class JWorkBook extends JTemplate { private static final int TOOLBARPANEDIMHEIGHT = 26; private UIModeControlContainer centerPane; - private ReportComponentComposite reportComposite; + public ReportComponentComposite reportComposite; private ParameterDefinitePane parameterPane; private int resolution; @@ -394,7 +394,7 @@ public class JWorkBook extends JTemplate { return resolution; } double time =(areaHeight/creatorHeight)<(areaWidth/creatorWidth) ? (areaHeight/creatorHeight) : (areaWidth/creatorWidth); - return (int) (time * polyDezi.getResolution()); + return (int) (time * ScreenResolution.getScreenResolution()); }else if (elementCasePane != null) { ElementCasePane reportPane = elementCasePane.getGrid().getElementCasePane(); diff --git a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java index 431a2ae5d9..f2e81e00af 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java @@ -23,6 +23,7 @@ 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.poly.PolyArea; import com.fr.report.report.TemplateReport; /** @@ -58,6 +59,8 @@ public class ReportComponentComposite extends JComponent { * */ public ReportComponentComposite(JWorkBook jwb) { + setFocusable(true); + setFocusTraversalKeysEnabled(false); this.parent = jwb; this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.add(centerCardPane = new ReportComponentCardPane(), BorderLayout.CENTER); @@ -135,6 +138,7 @@ public class ReportComponentComposite extends JComponent { return; } centerCardPane.populate(workbook.getTemplateReport(newIndex)); + if (parentContainer != null) { parentContainer.setDownPane(ReportComponentComposite.this); } @@ -184,6 +188,10 @@ public class ReportComponentComposite extends JComponent { return sheetNameTab.getSelectedIndex(); } + public JSliderPane getjSliderContainer(){ + return this.jSliderContainer; + } + public void setParentContainer(UIModeControlContainer parentContainer) { this.parentContainer = parentContainer; @@ -237,16 +245,6 @@ public class ReportComponentComposite extends JComponent { 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); diff --git a/designer/src/com/fr/poly/PolyDesigner.java b/designer/src/com/fr/poly/PolyDesigner.java index e2a25aeb6d..57413a1293 100644 --- a/designer/src/com/fr/poly/PolyDesigner.java +++ b/designer/src/com/fr/poly/PolyDesigner.java @@ -4,8 +4,7 @@ package com.fr.poly; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.MouseEvent; +import java.awt.event.*; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; @@ -98,18 +97,22 @@ public class PolyDesigner extends ReportComponent clip_board = new ArrayList(); // richer:鼠标滚轮每滚动一下,PolyDesignPane的尺寸就改变ROTATIONS这么多 private static final int ROTATIONS = 50; + private static final int MIN = 10; private JScrollBar verScrollBar; private JScrollBar horScrollBar; private PolyComponetsBar polyComponetsBar = new PolyComponetsBar(); private JComponent[] toolBarComponent = null; - + 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); @@ -119,11 +122,13 @@ public class PolyDesigner extends ReportComponent Date: Tue, 25 Jul 2017 11:07:08 +0800 Subject: [PATCH 18/18] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/ElementCasePane.java | 2 +- .../mainframe/ReportComponentComposite.java | 54 ++-- designer/src/com/fr/poly/PolyDesigner.java | 265 +++++++++--------- .../fr/design/mainframe/JFormSliderPane.java | 158 +++++------ .../com/fr/design/mainframe/JSliderPane.java | 176 ++++++------ 5 files changed, 322 insertions(+), 333 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/ElementCasePane.java b/designer/src/com/fr/design/mainframe/ElementCasePane.java index 7683d8c3bc..a04de95388 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePane.java +++ b/designer/src/com/fr/design/mainframe/ElementCasePane.java @@ -297,7 +297,7 @@ public abstract class ElementCasePane extends Tar if(DesignerContext.getReferencedElementCasePane() == null){ return; } - + ((ElementCasePane) DesignerContext.getReferencedElementCasePane()).getGrid().setNotShowingTableSelectPane(true); ((ElementCasePane) DesignerContext.getReferencedElementCasePane()).getGrid().setCursor(UIConstants.CELL_DEFAULT_CURSOR); DesignerContext.setReferencedElementCasePane(null); diff --git a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java index f2e81e00af..c54fd51b2b 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java @@ -1,17 +1,5 @@ package com.fr.design.mainframe; -import java.awt.BorderLayout; -import java.awt.event.*; -import java.util.ArrayList; - -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JSplitPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -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; @@ -23,9 +11,15 @@ 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.poly.PolyArea; 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 * @@ -56,7 +50,6 @@ public class ReportComponentComposite extends JComponent { /** * Constructor with workbook.. - * */ public ReportComponentComposite(JWorkBook jwb) { setFocusable(true); @@ -80,22 +73,24 @@ public class ReportComponentComposite extends JComponent { public void keyTyped(KeyEvent e) { } + @Override public void keyPressed(KeyEvent e) { - if( e.isControlDown()){ - isCtrl = true ; + if (e.isControlDown()) { + isCtrl = true; } } + @Override public void keyReleased(KeyEvent e) { - isCtrl = false ; + isCtrl = false; } }; MouseWheelListener showValSpinnerMouseWheelListener = new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { - if (isCtrl){ + if (isCtrl) { int dir = e.getWheelRotation(); int old_resolution = (int) jSliderContainer.getShowVal().getValue(); jSliderContainer.getShowVal().setValue(old_resolution - (dir * MIN)); @@ -106,10 +101,10 @@ public class ReportComponentComposite extends JComponent { ChangeListener showValSpinnerChangeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - double value = (int) ((UIBasicSpinner)e.getSource()).getValue(); + double value = (int) ((UIBasicSpinner) e.getSource()).getValue(); value = value > MAX ? MAX : value; value = value < MIN ? MIN : value; - int resolution = (int) (ScreenResolution.getScreenResolution()*value/HUND); + int resolution = (int) (ScreenResolution.getScreenResolution() * value / HUND); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution); } }; @@ -117,9 +112,9 @@ public class ReportComponentComposite extends JComponent { ItemListener selfAdaptButtonItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - if (jSliderContainer.getSelfAdaptButton().isSelected()){ + if (jSliderContainer.getSelfAdaptButton().isSelected()) { int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().selfAdaptUpdate(); - jSliderContainer.getShowVal().setValue(resolution*HUND/ScreenResolution.getScreenResolution()); + jSliderContainer.getShowVal().setValue(resolution * HUND / ScreenResolution.getScreenResolution()); } } }; @@ -166,11 +161,10 @@ public class ReportComponentComposite extends JComponent { } /** - * 移除选中状态 - * - * @date 2015-2-5-上午11:41:44 - * - */ + * 移除选中状态 + * + * @date 2015-2-5-上午11:41:44 + */ public void removeSelection() { if (centerCardPane.editingComponet instanceof WorkSheetDesigner) { ((WorkSheetDesigner) centerCardPane.editingComponet).removeSelection(); @@ -188,7 +182,7 @@ public class ReportComponentComposite extends JComponent { return sheetNameTab.getSelectedIndex(); } - public JSliderPane getjSliderContainer(){ + public JSliderPane getjSliderContainer() { return this.jSliderContainer; } @@ -240,8 +234,8 @@ 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; } diff --git a/designer/src/com/fr/poly/PolyDesigner.java b/designer/src/com/fr/poly/PolyDesigner.java index 57413a1293..088ef95e0e 100644 --- a/designer/src/com/fr/poly/PolyDesigner.java +++ b/designer/src/com/fr/poly/PolyDesigner.java @@ -3,20 +3,6 @@ */ package com.fr.poly; -import java.awt.*; -import java.awt.event.*; -import java.awt.image.BufferedImage; -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; @@ -47,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; @@ -61,13 +43,21 @@ import com.fr.report.block.Block; import com.fr.report.poly.PolyWorkSheet; import com.fr.report.poly.TemplateBlock; import com.fr.stable.ArrayUtils; -import com.fr.stable.CoreGraphHelper; import com.fr.stable.StringUtils; import com.fr.stable.unit.FU; 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 聚合报表的设计块,不包括底部和右边的滚动条以及左边和上边的像素标识条 @@ -85,6 +75,7 @@ public class PolyDesigner extends ReportComponent jt = DesignerContext.getDesignerFrame().getSelectedJTemplate(); - if(jt != null){ - jt.setComposite(); - } + if (jt != null) { + jt.setComposite(); + } DesignerContext.getDesignerFrame().resetToolkitByPlus(DesignerContext.getDesignerFrame().getSelectedJTemplate()); if (BaseUtils.isAuthorityEditing()) { EastRegionContainerPane.getInstance().replaceDownPane(RolesAlreadyEditedPane.getInstance()); @@ -918,8 +921,9 @@ public class PolyDesigner extends ReportComponent FOUR_HUNDRED){ + resolutionTimes = divide(showValue, 100, 2); + if (val > FOUR_HUNDRED) { showValSpinner.setValue(FOUR_HUNDRED); val = FOUR_HUNDRED; } - if (val < TEN){ + if (val < TEN) { showValSpinner.setValue(TEN); val = TEN; } @@ -197,11 +199,10 @@ public class JFormSliderPane extends JPanel { //定义一个监听器,用于监听所有滑动条 - ChangeListener listener = new ChangeListener() - { - public void stateChanged( ChangeEvent event) { + ChangeListener listener = new ChangeListener() { + public void stateChanged(ChangeEvent event) { //取出滑动条的值,并在文本中显示出来 - if (!isButtonOrIsTxt){ + if (!isButtonOrIsTxt) { customButton.setSelected(true); EventQueue.invokeLater(new Runnable() { public void run() { @@ -211,50 +212,50 @@ public class JFormSliderPane extends JPanel { showValSpinner.setValue(times); } }); - }else { + } else { isButtonOrIsTxt = false; } } }; - ItemListener radioButtonItemListener = new ItemListener() { + ItemListener radioButtonItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - JRadioButton temp=(JRadioButton)e.getSource(); - if(temp.isSelected()){ + JRadioButton temp = (JRadioButton) e.getSource(); + if (temp.isSelected()) { showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%")))); } } }; - private void refreshSlider(int val){ + 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 + 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+"%"); + 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() { @@ -262,22 +263,22 @@ public class JFormSliderPane extends JPanel { public void actionPerformed(ActionEvent e) { 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; showValSpinner.setValue(newDownVal); - }else { + } else { showValue = newDownVal; showValSpinner.setValue(TEN); } } - if(e.getActionCommand().equals("more")){ + if (e.getActionCommand().equals("more")) { int newUpVal = showValue + TEN; - if (newUpVal <= FOUR_HUNDRED ){ + if (newUpVal <= FOUR_HUNDRED) { showValue = newUpVal; showValSpinner.setValue(newUpVal); - }else { + } else { showValue = newUpVal; showValSpinner.setValue(FOUR_HUNDRED); } @@ -288,51 +289,49 @@ public class JFormSliderPane extends JPanel { }; - - 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); + 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(){ + public JSpinner getShowVal() { return this.showValSpinner; } - public UIRadioButton getSelfAdaptButton(){ + public UIRadioButton getSelfAdaptButton() { return this.selfAdaptButton; } - private void popupDialog(){ + private void popupDialog() { Point btnCoords = upButton.getLocationOnScreen(); - if (dialog == null){ - dialog = new FormPopupPane(upButton,dialogContentPanel); + 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); + GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); } - }else { + } else { if (upButtonX == 0) { upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOG_WIDTH + upButton.getWidth() +SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); + 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); + 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(JFormSliderPane.getInstance(),BorderLayout.CENTER); + content.add(JFormSliderPane.getInstance(), BorderLayout.CENTER); GUICoreUtils.centerWindow(jf); jf.setSize(400, 80); jf.setVisible(true); @@ -349,17 +348,18 @@ class FormPopupPane extends JPopupMenu { private static final int UPLABEL_WIDTH = 300; private JComponent centerPane; private UILabel upLabel; - FormPopupPane(UIButton b,JPanel dialogContentPanel) { + + 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.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); + 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)); diff --git a/designer_base/src/com/fr/design/mainframe/JSliderPane.java b/designer_base/src/com/fr/design/mainframe/JSliderPane.java index a14e106629..3feba5efa4 100644 --- a/designer_base/src/com/fr/design/mainframe/JSliderPane.java +++ b/designer_base/src/com/fr/design/mainframe/JSliderPane.java @@ -18,7 +18,10 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; 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; /** @@ -31,7 +34,7 @@ public class JSliderPane extends JPanel { 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_WIDTH = 45; private static final int SPINNER_HEIGHT = 20; private static final int HALF_HUNDRED = 50; private static final int HUNDRED = 100; @@ -69,7 +72,7 @@ public class JSliderPane extends JPanel { public JSliderPane() { this.setLayout(new BorderLayout()); - slider = new UISlider(0,HUNDRED,HALF_HUNDRED); + slider = new UISlider(0, HUNDRED, HALF_HUNDRED); slider.setUI(new JSliderPaneUI(slider)); slider.addChangeListener(listener); @@ -92,19 +95,19 @@ public class JSliderPane extends JPanel { downButton.addActionListener(buttonActionListener); upButton.addActionListener(buttonActionListener); - showValButton = new UIButton(showValSpinner.getValue()+"%"); + showValButton = new UIButton(showValSpinner.getValue() + "%"); showValButton.setBorderPainted(false); - showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH,SHOWVALBUTTON_HEIGHTH)); + showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH)); showValButton.addActionListener(showValButtonActionListener); initUIRadioButton(); initPane(); - JPanel panel = new JPanel(new FlowLayout(1,1,0)); + 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); + this.add(panel, BorderLayout.NORTH); + this.setBounds(0, 0, THREE_HUNDRED, ONE_EIGHT); } public static final JSliderPane getInstance() { @@ -115,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%"); @@ -131,7 +134,7 @@ public class JSliderPane extends JPanel { //TODO // selfAdaptButton.addItemListener(); - ButtonGroup bg=new ButtonGroup();// 初始化按钮组 + ButtonGroup bg = new ButtonGroup();// 初始化按钮组 bg.add(twoHundredButton);// 加入按钮组 bg.add(oneHundredButton); bg.add(SevenFiveButton); @@ -142,24 +145,24 @@ public class JSliderPane extends JPanel { customButton.setSelected(true); } - private void initPane(){ + private void initPane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] columnSize = { p, f }; - double[] rowSize = { p,p,p,p,p,p,p}; + 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()} + 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); + dialogContentPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } - private JPanel createSpinnerPanel(){ + private JPanel createSpinnerPanel() { JPanel spinnerPanel = new JPanel(new FlowLayout()); spinnerPanel.add(showValSpinner); UILabel percent = new UILabel("%"); @@ -178,14 +181,14 @@ public class JSliderPane extends JPanel { ChangeListener showValSpinnerChangeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - int val = (int) ((UIBasicSpinner)e.getSource()).getValue(); + int val = (int) ((UIBasicSpinner) e.getSource()).getValue(); isButtonOrIsTxt = true; - resolutionTimes = divide(showValue,100,2); - if (val > FOUR_HUNDRED){ + resolutionTimes = divide(showValue, 100, 2); + if (val > FOUR_HUNDRED) { showValSpinner.setValue(FOUR_HUNDRED); val = FOUR_HUNDRED; } - if (val < TEN){ + if (val < TEN) { showValSpinner.setValue(TEN); val = TEN; } @@ -196,11 +199,10 @@ public class JSliderPane extends JPanel { //定义一个监听器,用于监听所有滑动条 - ChangeListener listener = new ChangeListener() - { - public void stateChanged( ChangeEvent event) { + ChangeListener listener = new ChangeListener() { + public void stateChanged(ChangeEvent event) { //取出滑动条的值,并在文本中显示出来 - if (!isButtonOrIsTxt){ + if (!isButtonOrIsTxt) { customButton.setSelected(true); EventQueue.invokeLater(new Runnable() { public void run() { @@ -210,50 +212,50 @@ public class JSliderPane extends JPanel { showValSpinner.setValue(times); } }); - }else { + } else { isButtonOrIsTxt = false; } } }; - ItemListener radioButtonItemListener = new ItemListener() { + ItemListener radioButtonItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - JRadioButton temp=(JRadioButton)e.getSource(); - if(temp.isSelected()){ + JRadioButton temp = (JRadioButton) e.getSource(); + if (temp.isSelected()) { showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%")))); } } }; - private void refreshSlider(int val){ + 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 + 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+"%"); + 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() { @@ -261,22 +263,22 @@ public class JSliderPane extends JPanel { public void actionPerformed(ActionEvent e) { 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; showValSpinner.setValue(newDownVal); - }else { + } else { showValue = newDownVal; showValSpinner.setValue(TEN); } } - if(e.getActionCommand().equals("more")){ + if (e.getActionCommand().equals("more")) { int newUpVal = showValue + TEN; - if (newUpVal <= FOUR_HUNDRED ){ + if (newUpVal <= FOUR_HUNDRED) { showValue = newUpVal; showValSpinner.setValue(newUpVal); - }else { + } else { showValue = newUpVal; showValSpinner.setValue(FOUR_HUNDRED); } @@ -287,51 +289,49 @@ public class JSliderPane extends JPanel { }; - - 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); + 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(){ + public JSpinner getShowVal() { return this.showValSpinner; } - public UIRadioButton getSelfAdaptButton(){ + public UIRadioButton getSelfAdaptButton() { return this.selfAdaptButton; } - private void popupDialog(){ + private void popupDialog() { Point btnCoords = upButton.getLocationOnScreen(); - if (dialog == null){ - dialog = new PopupPane(upButton,dialogContentPanel); + if (dialog == null) { + dialog = new PopupPane(upButton, dialogContentPanel); if (upButtonX == 0) { upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH , -DIALOG_HEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); } - }else { + } else { if (upButtonX == 0) { upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOG_WIDTH + upButton.getWidth() +SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); + 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); + 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); @@ -359,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; } @@ -377,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); } /** */ @@ -399,8 +397,8 @@ 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); } @@ -416,17 +414,18 @@ class PopupPane extends JPopupMenu { private static final int UPLABEL_WIDTH = 300; private JComponent centerPane; private UILabel upLabel; - PopupPane(UIButton b,JPanel dialogContentPanel) { + + 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.setOpaque(true); - upLabel.setPreferredSize(new Dimension(UPLABEL_WIDTH,UPLABEL_HEIGHT)); + 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); + 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)); @@ -434,5 +433,4 @@ class PopupPane extends JPopupMenu { } - } \ No newline at end of file