From d166a5891a0cffe93fb7d1dc718bbc260d05d09f Mon Sep 17 00:00:00 2001 From: vito Date: Mon, 17 Jan 2022 17:52:37 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-64443=20=E5=85=AC=E5=BC=8F=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D=E6=8A=A5=E9=94=99=E8=B7=B3=E8=BD=AC=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JTemplate.java | 16 ++- .../form/FormECDesignerProvider.java | 12 +- .../loghandler/DesignerLogHandler.java | 132 +++++++++++++++++- .../com/fr/design/selection/Selectedable.java | 28 ++-- .../fr/design/designer/creator/XCreator.java | 11 ++ .../main/java/com/fr/design/fit/NewJForm.java | 33 ++++- .../java/com/fr/design/mainframe/JForm.java | 52 ++++++- .../com/fr/design/mainframe/JWorkBook.java | 23 +-- .../mainframe/ReportComponentComposite.java | 23 ++- .../design/mainframe/WorkSheetDesigner.java | 27 ++++ .../form/FormElementCaseDesigner.java | 28 ++++ .../main/java/com/fr/poly/PolyDesigner.java | 35 ++++- .../java/com/fr/poly/creator/ECBlockPane.java | 29 ++++ 13 files changed, 403 insertions(+), 46 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index f1a40ccdc..f37b817e9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.Parameter; +import com.fr.base.TRL; import com.fr.base.extension.FileExtension; import com.fr.base.io.BaseBook; import com.fr.base.iofile.attr.DesignBanCopyAttrMark; @@ -105,9 +106,9 @@ import javax.swing.JOptionPane; import javax.swing.SwingConstants; import javax.swing.undo.UndoManager; import java.awt.BorderLayout; -import java.io.ByteArrayOutputStream; import java.awt.Dimension; import java.awt.FontMetrics; +import java.io.ByteArrayOutputStream; import java.util.Set; import java.util.concurrent.Callable; @@ -1000,7 +1001,7 @@ public abstract class JTemplate> return true; } - public boolean isNewCreateTpl(){ + public boolean isNewCreateTpl() { return isNewCreateTpl; } @@ -1543,7 +1544,7 @@ public abstract class JTemplate> /** * 设置新引擎后,有不支持的功能时,设计器中模板的标题需要加上“兼容模式”或者“不支持分页引擎”来提示用户 - * */ + */ private String compatibilityTip() { if (!CptAndCptxCompatibilityUtil.isEngineXEnable(this.getTarget(), getEditingFILE().getPath())) { return StringUtils.EMPTY; @@ -1888,6 +1889,15 @@ public abstract class JTemplate> templateThemeButton.setToolTipText(name); } + /** + * 定位 + * + * @param trl + */ + public void navigate(TRL trl) { + + } + public void generateForBiddenTemplate() { } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/form/FormECDesignerProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/form/FormECDesignerProvider.java index 88a462307..2dc68704e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/form/FormECDesignerProvider.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/form/FormECDesignerProvider.java @@ -1,10 +1,6 @@ package com.fr.design.mainframe.form; -import java.awt.Dimension; -import java.awt.image.BufferedImage; - -import javax.swing.JComponent; - +import com.fr.base.TRL; import com.fr.design.designer.TargetComponent; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.MenuDef; @@ -12,6 +8,10 @@ import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.form.FormElementCaseProvider; +import javax.swing.JComponent; +import java.awt.Dimension; +import java.awt.image.BufferedImage; + public interface FormECDesignerProvider { String XML_TAG = "FormElementCaseDesigner"; @@ -92,4 +92,6 @@ public interface FormECDesignerProvider { void refreshPropertyPane(); void removeSelection(); + + default void navigate(TRL trl) {} } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index 1cb8e5d1a..f7ffe1aae 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java @@ -1,31 +1,43 @@ package com.fr.design.mainframe.loghandler; import com.fr.base.BaseUtils; +import com.fr.base.TRL; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; import com.fr.design.ui.util.UIUtil; +import com.fr.file.FILEFactory; import com.fr.general.ComparatorUtils; import com.fr.general.log.Log4jConfig; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; - +import com.fr.stable.project.ProjectConstants; import com.fr.third.apache.logging.log4j.Level; import com.fr.third.apache.logging.log4j.core.LogEvent; +import org.jetbrains.annotations.Nullable; + import javax.swing.AbstractAction; import javax.swing.ActionMap; import javax.swing.InputMap; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComponent; +import javax.swing.JEditorPane; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JTextPane; import javax.swing.KeyStroke; +import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.DefaultEditorKit; import javax.swing.text.Document; +import javax.swing.text.Element; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleConstants; +import javax.swing.text.html.HTML; +import javax.swing.text.html.HTMLDocument; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -36,8 +48,14 @@ import java.awt.event.ItemListener; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.io.File; +import java.io.IOException; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; @@ -61,6 +79,8 @@ public class DesignerLogHandler { private static final String ACTION_MAP_KEY = "clear"; + private static final Pattern pattern = Pattern.compile("\\([^(]*.(?>cpt|frm|cptx)[^)]*\\)"); + public static DesignerLogHandler getInstance() { return HOLDER.singleton; @@ -215,13 +235,61 @@ public class DesignerLogHandler { popup.show(jTextArea, event.getX(), event.getY()); checkEnabled(); } + if (event.getButton() == MouseEvent.BUTTON1) { + String url = findTplLinkFromMouseEvent(event); + if (StringUtils.isNotEmpty(url)) { + navigate(url); + } + } } }); } + /** + * 将模板定位链接导航到指定的位置 + * + * @param href 模板定位链接 + */ + private void navigate(String href) { + if (!href.startsWith(TRL.PREFIX)) { + return; + } + TRL trl = new TRL(href); + DesignerContext.getDesignerFrame().openTemplate(FILEFactory.createFILE(ProjectConstants.REPORTLETS_NAME + File.separator + trl.getTemplatePath())); + JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (currentEditingTemplate != null) { + currentEditingTemplate.navigate(trl); + } + } + + /** + * 鼠标事件中定位到模板链接 + * + * @param event 鼠标事件 + * @return 模板链接 + */ + private String findTplLinkFromMouseEvent(MouseEvent event) { + JEditorPane editor = (JEditorPane) event.getSource(); + int pos = editor.getUI().viewToModel(editor, event.getPoint()); + if (pos >= 0 && editor.getDocument() instanceof HTMLDocument) { + HTMLDocument hdoc = (HTMLDocument) editor.getDocument(); + Element elem = hdoc.getCharacterElement(pos); + Object a = elem.getAttributes().getAttribute(HTML.Tag.A); + if (a instanceof AttributeSet) { + AttributeSet set = (AttributeSet) a; + String url = (String) set.getAttribute(HTML.Attribute.HREF); + if (StringUtils.isNotEmpty(url)) { + return url; + } + } + } + return StringUtils.EMPTY; + } + private JTextPane initLogJTextArea() { final JTextPane resultPane = new JTextPane(); + resultPane.setContentType("text/html"); InputMap inputMap = resultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), DefaultEditorKit.selectAllAction); @@ -294,6 +362,12 @@ public class DesignerLogHandler { SimpleAttributeSet attrSet = new SimpleAttributeSet(); if (style == DesignerLogger.ERROR_INT) { + String[] tplLink = tryFindTplLink(str); + if (tplLink != null + && tplLink.length > 0 + && dealWithTplLink(str, tplLink)) { + return; + } StyleConstants.setForeground(attrSet, Color.RED); StyleConstants.setBold(attrSet, true); } else if (style == DesignerLogger.WARN_INT) { @@ -314,6 +388,62 @@ public class DesignerLogHandler { } } + /** + * 处理模板链接 + * + * @param s 含有模板链接 + * @param tplLink 模板链接 + * @return 是否处理成功 + */ + private boolean dealWithTplLink(String s, String[] tplLink) { + String afterBr = s.replaceAll("\\n", "
"); + String[] lineSeg = pattern.split(afterBr); + StringBuilder sb = new StringBuilder(""); + for(int i=0;i< tplLink.length;i++){ + sb.append("") + .append(lineSeg[i]) + .append("") + .append(tplLink[i]) + .append(""); + } + if (lineSeg.length > tplLink.length) { + sb.append("").append(lineSeg[lineSeg.length-1]).append(""); + } + sb.append(""); + + try { + Document doc = jTextArea.getStyledDocument(); + HTMLDocument htmlDocument = (HTMLDocument) doc; + htmlDocument.insertAfterEnd(htmlDocument.getCharacterElement(doc.getLength()), sb.toString()); + } catch (BadLocationException | IOException ignored) { + // 这里出问题不记录日志否则会导致死循环 + return false; + } + return true; + } + + /** + * 尝试找到模板链接 + * + * @param s 可能含有模板链接的字符串 + * @return 模板链接 + */ + @Nullable + private String[] tryFindTplLink(String s) { + Document doc = jTextArea.getStyledDocument(); + if (!(doc instanceof HTMLDocument)) { + return null; + } + Matcher matcher = pattern.matcher(s); + List list = new ArrayList<>(); + while (matcher.find()) { + list.add(matcher.group(0)); + } + return list.toArray(new String[0]); + } + private String appendLocaleMark(String str, int style) { if (style == DesignerLogger.ERROR_INT) { diff --git a/designer-base/src/main/java/com/fr/design/selection/Selectedable.java b/designer-base/src/main/java/com/fr/design/selection/Selectedable.java index 5e78482e8..890005443 100644 --- a/designer-base/src/main/java/com/fr/design/selection/Selectedable.java +++ b/designer-base/src/main/java/com/fr/design/selection/Selectedable.java @@ -1,25 +1,29 @@ package com.fr.design.selection; +import com.fr.base.TRL; + /** - * * @author zhou * @since 2012-7-26上午10:20:32 */ public interface Selectedable { - public S getSelection(); + S getSelection(); + + void setSelection(S selectElement); - public void setSelection(S selectElement); + /** + * Adds a ChangeListener to the listener list. + */ + void addSelectionChangeListener(SelectionListener selectionListener); - /** - * Adds a ChangeListener to the listener list. - */ - public void addSelectionChangeListener(SelectionListener selectionListener); + /** + * removes a ChangeListener from the listener list. + */ + void removeSelectionChangeListener(SelectionListener selectionListener); - /** - * removes a ChangeListener from the listener list. - */ - public void removeSelectionChangeListener(SelectionListener selectionListener); + // august:这儿就不要加fireSelectionChangeListener方法了。因为这个方法一般要定义成私有的,不然外部随即的调用! + default void navigate(TRL trl) { - // august:这儿就不要加fireSelectionChangeListener方法了。因为这个方法一般要定义成私有的,不然外部随即的调用! + } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index 14fc9ea24..792e97045 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -54,6 +54,7 @@ import java.beans.IntrospectionException; import java.util.ArrayList; import java.util.List; import java.util.Set; +import java.util.StringJoiner; /** * @author richer @@ -943,4 +944,14 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo return false; } + + @Override + public String toString() { + return new StringJoiner(", ", XCreator.class.getSimpleName() + "[", "]") + .add("data=" + data) + .add("shareId='" + shareId + "'") + .add("isHelpBtnOnFocus=" + isHelpBtnOnFocus) + .add("selected=" + selected) + .toString(); + } } diff --git a/designer-form/src/main/java/com/fr/design/fit/NewJForm.java b/designer-form/src/main/java/com/fr/design/fit/NewJForm.java index 0a12a7425..60bd8d542 100644 --- a/designer-form/src/main/java/com/fr/design/fit/NewJForm.java +++ b/designer-form/src/main/java/com/fr/design/fit/NewJForm.java @@ -2,25 +2,27 @@ package com.fr.design.fit; import com.fr.base.DynamicUnitList; import com.fr.base.Parameter; +import com.fr.base.TRL; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter; import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XComponent; +import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XElementCase; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWTitleLayout; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.mainframe.DesignerUIModeConfig; -import com.fr.design.preview.DeveloperPreview; -import com.fr.design.preview.FormAdaptivePreview; import com.fr.design.fit.toolbar.SwitchAction; import com.fr.design.fun.PreviewProvider; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.preview.DeveloperPreview; +import com.fr.design.preview.FormAdaptivePreview; import com.fr.design.preview.FormPreview; import com.fr.design.preview.MobilePreview; import com.fr.design.utils.ComponentUtils; @@ -29,6 +31,7 @@ import com.fr.form.FormElementCaseProvider; import com.fr.form.fit.NewFormMarkAttr; import com.fr.form.main.Form; import com.fr.form.ui.ElementCaseEditor; +import com.fr.general.ComparatorUtils; import com.fr.stable.ArrayUtils; import javax.swing.JComponent; @@ -215,6 +218,7 @@ public class NewJForm extends JForm { return new PreviewProvider[]{new FormPreview(), new MobilePreview()}; } + @Override public UIButton[] createExtraButtons() { UIButton[] extraButtons = super.createExtraButtons(); return addAdaptiveSwitchButton(extraButtons); @@ -228,4 +232,25 @@ public class NewJForm extends JForm { public boolean isNewJFrom() { return jFormType == null || jFormType.isNewType(); } + + @Override + public void navigate(TRL trl) { + String blockName = trl.unescapeNext(); + JForm.traversalXCreator(formDesign.getRootComponent(), xCreator -> { + if (!ComparatorUtils.equals(xCreator.toData().getWidgetName(), blockName)) { + return; + } + if (xCreator instanceof XElementCase) { + getFormDesign().getSelectionModel().selectACreator(xCreator); + xCreator.startEditing(); + if (getElementCaseDesign() != null) { + getElementCaseDesign().navigate(trl); + } + } else { + tabChanged(FORM_TAB); + getFormDesign().getSelectionModel().reset(); + getFormDesign().getSelectionModel().selectACreator(xCreator); + } + }, XCreator.class); + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index ec3852437..449aa5190 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -96,6 +96,7 @@ import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.bridge.StableFactory; import com.fr.web.controller.ViewRequestConstants; +import org.jetbrains.annotations.Nullable; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -125,7 +126,7 @@ public class JForm extends JTemplate implements BaseJForm implements BaseJForm implements BaseJForm implements BaseJForm implements BaseJForm implements BaseJForm implements BaseJForm { } protected void addShortCut(MenuDef exportMenuDef, MenuDef excelExportMenuDef) { - if (CptAndCptxCompatibilityUtil.isEngineXEnable(this.getTarget(), getEditingFILE().getPath())){ + if (CptAndCptxCompatibilityUtil.isEngineXEnable(this.getTarget(), getEditingFILE().getPath())) { exportMenuDef.addShortCut(excelExportMenuDef, new PDFExportAction(this), new WordExportAction(this), new SVGExportAction(this), new CSVExportAction(this), new TextExportAction(this)); - }else { + } else { exportMenuDef.addShortCut(excelExportMenuDef, new PDFExportAction(this), new WordExportAction(this), new SVGExportAction(this), new CSVExportAction(this), new TextExportAction(this), new EmbeddedExportExportAction(this)); } @@ -758,15 +758,14 @@ public class JWorkBook extends JTemplate { new ReportWatermarkAction(this), new NameSeparator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Current_Sheet")), }, this.reportComposite.getEditingReportComponent().shortcut4TemplateMenu()); - if (enableNewEngine){ + if (enableNewEngine) { return ArraysUtil.insert(commonShortCut, new CalculateAttrAction(this), 5); - }else { + } else { return commonShortCut; } } - /** * 模板的工具 * @@ -1243,6 +1242,7 @@ public class JWorkBook extends JTemplate { return ViewRequestConstants.REPORT_VIEW_PATH; } + @Override protected void addChooseFILEFilter(FILEChooserPane fileChooser) { String appName = ProductConstants.APP_NAME; fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPT, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); @@ -1304,7 +1304,7 @@ public class JWorkBook extends JTemplate { @Override public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) { - ReportTheme oldTheme = getTarget().getTemplateTheme(); + ReportTheme oldTheme = getTarget().getTemplateTheme(); boolean shouldCreateUndoState = compatible == TemplateThemeCompatible.NONE && !StringUtils.equals(oldTheme.getName(), newTheme.getName()); getTarget().setTemplateTheme(newTheme, compatible); @@ -1318,4 +1318,9 @@ public class JWorkBook extends JTemplate { super.setTemplateTheme(newTheme, compatible); } + + @Override + public void navigate(TRL trl) { + reportComposite.selectCell(trl); + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java index 5fe561829..d0f6a114d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe; import com.fr.base.ScreenResolution; -import com.fr.common.inputevent.InputEventBaseOnOS; +import com.fr.base.TRL; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.designer.EditingState; import com.fr.design.event.RemoveListener; @@ -13,14 +13,13 @@ import com.fr.grid.Grid; import com.fr.log.FineLoggerFactory; import com.fr.main.impl.WorkBook; import com.fr.report.report.TemplateReport; +import com.fr.stable.StringUtils; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.BorderLayout; -import java.awt.event.MouseWheelEvent; -import java.awt.event.MouseWheelListener; import java.util.ArrayList; /** @@ -80,6 +79,22 @@ public class ReportComponentComposite extends JComponent implements RemoveListen } }; + /** + * 选中格子 + * + * @param trl 模板资源路径 + */ + public void selectCell(TRL trl) { + String sheetIndexStr = trl.next(); + if(StringUtils.isEmpty(sheetIndexStr)) { + return; + } + int sheetIndex = Integer.parseInt(sheetIndexStr); + if (sheetIndex >= 0) { + sheetNameTab.setSelectedIndex(sheetIndex); + centerCardPane.editingComponet.navigate(trl); + } + } protected void doBeforeChange(int oldIndex) { if (oldIndex >= 0) { @@ -131,7 +146,7 @@ public class ReportComponentComposite extends JComponent implements RemoveListen } } - private void updateJSlider(){ + private void updateJSlider() { centerCardPane.editingComponet.updateJSliderValue(); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java b/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java index da7548013..0529cf82a 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe; import com.fr.base.ScreenResolution; +import com.fr.base.TRL; import com.fr.design.DesignState; import com.fr.design.actions.report.ReportColumnsAction; import com.fr.design.actions.report.ReportEngineAttrAction; @@ -19,11 +20,14 @@ import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.design.selection.SelectionListener; import com.fr.grid.selection.CellSelection; +import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; import com.fr.report.cell.CellElement; import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.worksheet.WorkSheet; import com.fr.stable.ArrayUtils; +import com.fr.stable.ColumnRow; +import com.fr.stable.StringUtils; import javax.swing.JComponent; import javax.swing.JPanel; @@ -196,4 +200,27 @@ public class WorkSheetDesigner extends ReportComponent 10000) { + setSelection(new FloatSelection(TRL.unescape(cellName))); + return; + } + CellSelection cellSelection = new CellSelection(columnRow.getColumn(), columnRow.getRow(), columnRow.getColumnSpan(), columnRow.getRowSpan()); + // 滚动到位 + JScrollBar verticalBar = getVerticalScrollBar(), + horizontalBar = getHorizontalScrollBar(); + int m = columnRow.getColumn(), n = columnRow.getRow(); + verticalBar.setMaximum(n); + verticalBar.setValue(n < 21 ? verticalBar.getValue() : n - 20); + horizontalBar.setMaximum(m); + horizontalBar.setValue(m < 13 ? horizontalBar.getValue() : m - 12); + // 选中 + setSelection(cellSelection); + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java index 9d89a7cd3..481ab540b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java @@ -3,6 +3,7 @@ */ package com.fr.design.mainframe.form; +import com.fr.base.TRL; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignState; import com.fr.design.actions.AllowAuthorityEditAction; @@ -32,13 +33,16 @@ import com.fr.form.FormElementCaseProvider; import com.fr.form.main.Form; import com.fr.grid.Grid; import com.fr.grid.selection.CellSelection; +import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; import com.fr.log.FineLoggerFactory; import com.fr.report.cell.CellElement; import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.worksheet.FormElementCase; import com.fr.report.worksheet.WorkSheet; +import com.fr.stable.ColumnRow; import com.fr.stable.Constants; +import com.fr.stable.StringUtils; import javax.swing.JComponent; import javax.swing.JPanel; @@ -389,4 +393,28 @@ public class FormElementCaseDesigner public FormElementCaseProvider getEditingElementCase() { return this.getEditingElementCasePane().getTarget(); } + + @Override + public void navigate(TRL trl) { + String cellName = trl.next(); + if (StringUtils.isEmpty(cellName)) { + return; + } + ColumnRow columnRow = ColumnRow.valueOf(cellName); + if (!ColumnRow.validate(columnRow) || columnRow.getColumn() > 10000) { + setSelection((S)new FloatSelection(TRL.unescape(cellName))); + return; + } + CellSelection cellSelection = new CellSelection(columnRow.getColumn(), columnRow.getRow(), columnRow.getColumnSpan(), columnRow.getRowSpan()); + // 滚动到位 + JScrollBar verticalBar = getVerticalScrollBar(), + horizontalBar = getHorizontalScrollBar(); + int m = columnRow.getColumn(), n = columnRow.getRow(); + verticalBar.setMaximum(n); + verticalBar.setValue(n < 21 ? verticalBar.getValue() : n - 20); + horizontalBar.setMaximum(m); + horizontalBar.setValue(m < 13 ? horizontalBar.getValue() : m - 12); + // 选中 + setSelection((S)cellSelection); + } } diff --git a/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java b/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java index 437cb8ea1..494b7e4c6 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java @@ -5,6 +5,7 @@ package com.fr.poly; import com.fr.base.GraphHelper; import com.fr.base.ScreenResolution; +import com.fr.base.TRL; import com.fr.base.vcs.DesignerMode; import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.design.DesignState; @@ -65,6 +66,7 @@ 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 org.jetbrains.annotations.Nullable; import javax.swing.AbstractAction; import javax.swing.ActionMap; @@ -124,7 +126,7 @@ public class PolyDesigner extends ReportComponent 0 && elementCasePane != null) { + elementCasePane.navigate(trl); + } + + } + + @Nullable + private BlockCreator getBlock(String blockName) { + for (int i = 0; i < addedData.getAddedCount(); i++) { + BlockCreator creator = addedData.getAddedAt(i); + if (ComparatorUtils.equals(blockName, creator.getValue().getBlockName())) { + return creator; + } + } + return null; + } } diff --git a/designer-realize/src/main/java/com/fr/poly/creator/ECBlockPane.java b/designer-realize/src/main/java/com/fr/poly/creator/ECBlockPane.java index 9a584836b..33bcda20a 100644 --- a/designer-realize/src/main/java/com/fr/poly/creator/ECBlockPane.java +++ b/designer-realize/src/main/java/com/fr/poly/creator/ECBlockPane.java @@ -3,6 +3,7 @@ */ package com.fr.poly.creator; +import com.fr.base.TRL; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignState; import com.fr.design.actions.UpdateAction; @@ -32,11 +33,16 @@ import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionListener; +import com.fr.grid.selection.CellSelection; +import com.fr.grid.selection.FloatSelection; import com.fr.page.ReportSettingsProvider; import com.fr.poly.PolyDesigner; import com.fr.report.poly.PolyECBlock; import com.fr.stable.ArrayUtils; +import com.fr.stable.ColumnRow; +import com.fr.stable.StringUtils; +import javax.swing.JScrollBar; import java.awt.Dimension; /** @@ -171,4 +177,27 @@ public class ECBlockPane extends PolyElementCasePane { return designer.getTemplateReport().getReportSettings(); } + @Override + public void navigate(TRL trl) { + String cellName = trl.next(); + if (StringUtils.isEmpty(cellName)) { + return; + } + ColumnRow columnRow = ColumnRow.valueOf(cellName); + if (!ColumnRow.validate(columnRow) || columnRow.getColumn() > 10000) { + setSelection(new FloatSelection(TRL.unescape(cellName))); + return; + } + CellSelection cellSelection = new CellSelection(columnRow.getColumn(), columnRow.getRow(), columnRow.getColumnSpan(), columnRow.getRowSpan()); + // 滚动到位 + JScrollBar verticalBar = getVerticalScrollBar(), + horizontalBar = getHorizontalScrollBar(); + int m = columnRow.getColumn(), n = columnRow.getRow(); + verticalBar.setMaximum(n); + verticalBar.setValue(n < 21 ? verticalBar.getValue() : n - 20); + horizontalBar.setMaximum(m); + horizontalBar.setValue(m < 13 ? horizontalBar.getValue() : m - 12); + // 选中 + setSelection(cellSelection); + } }