Browse Source

Pull request #7620: REPORT-64443 公式定位报错跳转支持

Merge in DESIGN/design from ~VITO/c-design:feature/x to feature/x

* commit 'd166a5891a0cffe93fb7d1dc718bbc260d05d09f':
  REPORT-64443 公式定位报错跳转支持
feature/x
vito 3 years ago
parent
commit
f3b7bac5d7
  1. 16
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  2. 12
      designer-base/src/main/java/com/fr/design/mainframe/form/FormECDesignerProvider.java
  3. 132
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  4. 28
      designer-base/src/main/java/com/fr/design/selection/Selectedable.java
  5. 11
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  6. 33
      designer-form/src/main/java/com/fr/design/fit/NewJForm.java
  7. 52
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  8. 23
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  9. 23
      designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java
  10. 27
      designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java
  11. 28
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java
  12. 35
      designer-realize/src/main/java/com/fr/poly/PolyDesigner.java
  13. 29
      designer-realize/src/main/java/com/fr/poly/creator/ECBlockPane.java

16
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<T extends BaseBook, U extends BaseUndoState<?>>
return true;
}
public boolean isNewCreateTpl(){
public boolean isNewCreateTpl() {
return isNewCreateTpl;
}
@ -1543,7 +1544,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
/**
* 设置新引擎后有不支持的功能时设计器中模板的标题需要加上兼容模式或者不支持分页引擎来提示用户
* */
*/
private String compatibilityTip() {
if (!CptAndCptxCompatibilityUtil.isEngineXEnable(this.getTarget(), getEditingFILE().getPath())) {
return StringUtils.EMPTY;
@ -1888,6 +1889,15 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
templateThemeButton.setToolTipText(name);
}
/**
* 定位
*
* @param trl
*/
public void navigate(TRL trl) {
}
public void generateForBiddenTemplate() {
}

12
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) {}
}

132
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", "<br/>");
String[] lineSeg = pattern.split(afterBr);
StringBuilder sb = new StringBuilder("<span style=\"font-weight: bold;font-size:" + jTextArea.getFont().getSize() + "\">");
for(int i=0;i< tplLink.length;i++){
sb.append("<span style=\"color:red;\">")
.append(lineSeg[i])
.append("</span><a href=\"tpl://")
.append(tplLink[i], 1, tplLink[i].length() - 1)
.append("\">")
.append(tplLink[i])
.append("</a>");
}
if (lineSeg.length > tplLink.length) {
sb.append("<span style=\"color:red;\">").append(lineSeg[lineSeg.length-1]).append("</span>");
}
sb.append("</span>");
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<String> 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) {

28
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<S extends SelectableElement> {
public S getSelection();
S getSelection();
void setSelection(S selectElement);
public void setSelection(S selectElement);
/**
* Adds a <code>ChangeListener</code> to the listener list.
*/
void addSelectionChangeListener(SelectionListener selectionListener);
/**
* Adds a <code>ChangeListener</code> to the listener list.
*/
public void addSelectionChangeListener(SelectionListener selectionListener);
/**
* removes a <code>ChangeListener</code> from the listener list.
*/
void removeSelectionChangeListener(SelectionListener selectionListener);
/**
* removes a <code>ChangeListener</code> from the listener list.
*/
public void removeSelectionChangeListener(SelectionListener selectionListener);
// august:这儿就不要加fireSelectionChangeListener方法了。因为这个方法一般要定义成私有的,不然外部随即的调用!
default void navigate(TRL trl) {
// august:这儿就不要加fireSelectionChangeListener方法了。因为这个方法一般要定义成私有的,不然外部随即的调用!
}
}

11
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();
}
}

33
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);
}
}

52
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<Form, FormUndoState> implements BaseJForm<F
private static final int TOOLBARPANEDIMHEIGHT_FORM = 60;
//表单设计器
private FormDesigner formDesign;
protected FormDesigner formDesign;
//格子设计器
private FormECDesignerProvider elementCaseDesign;
@ -134,7 +135,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
private CardLayout cardLayout;
//当前编辑的组件对象
private JComponent editingComponent;
private FormECCompositeProvider reportComposite;
protected FormECCompositeProvider reportComposite;
//FORM_TAB代表是否点击编辑,用于点击编辑前后菜单的显示
protected int index = FORM_TAB;
@ -742,7 +743,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
*/
public JComponent[] toolBarButton4Form() {
return this.index == FORM_TAB ?
formDesign.getBasicActionComponent():
formDesign.getBasicActionComponent() :
elementCaseDesign.toolBarButton4Form();
}
@ -928,6 +929,9 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
* @param index 切换位置
*/
public void tabChanged(int index) {
if (this.index == index) {
return;
}
this.index = index;
if (index == ELEMENTCASE_TAB) {
formDesign.setReportBlockEditing(true);
@ -1050,6 +1054,42 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
return creator.toData();
}
/**
* 选中组件
*
* @param widgetName 组件名称
*/
public void selectElementCase(String widgetName) {
XCreator elementCase = findElementCase(formDesign.getRootComponent(), widgetName);
if (elementCase == null) {
return;
}
formDesign.getSelectionModel().reset();
formDesign.getSelectionModel().setSelectedCreator(elementCase);
elementCase.startEditing();
}
@Nullable
public XCreator findElementCase(XLayoutContainer container, String name) {
if (StringUtils.equals(container.toData().getWidgetName(), name)) {
return container;
}
for (Component component : container.getComponents()) {
if (component instanceof XLayoutContainer) {
XCreator xCreator = findElementCase((XLayoutContainer) component, name);
if (xCreator != null) {
return xCreator;
}
} else if (component instanceof XCreator) {
XCreator xCreator = (XCreator) component;
if (StringUtils.equals(xCreator.toData().getWidgetName(), name)) {
return xCreator;
}
}
}
return null;
}
/**
* 支持的预览模式
*
@ -1107,7 +1147,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
}
Iterator tdIterator = sharableEditor.getTableDataSource().getTableDataNameIterator();
while (tdIterator.hasNext()) {
String tdName = bindInfo.getName() + TableDataConstants.SEPARATOR + tdIterator.next();
String tdName = bindInfo.getName() + TableDataConstants.SEPARATOR + tdIterator.next();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).removeTableData(tdName);
}
}
@ -1230,11 +1270,11 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showForbiddenStatus();
}
public void setDesignerUIMode(){
public void setDesignerUIMode() {
DesignerUIModeConfig.getInstance().setSimulateWebUIMode();
}
public XLayoutContainer getRootComponent(){
public XLayoutContainer getRootComponent() {
return this.formDesign.getRootComponent();
}
}

23
designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

@ -4,13 +4,13 @@ import com.fr.base.BaseUtils;
import com.fr.base.DynamicUnitList;
import com.fr.base.Parameter;
import com.fr.base.ScreenResolution;
import com.fr.base.TRL;
import com.fr.base.extension.FileExtension;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.base.vcs.DesignerMode;
import com.fr.base.theme.ReportTheme;
import com.fr.base.theme.ReportThemeConfig;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.AllowAuthorityEditAction;
@ -717,10 +717,10 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
}
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<WorkBook, WorkBookUndoState> {
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<WorkBook, WorkBookUndoState> {
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<WorkBook, WorkBookUndoState> {
@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<WorkBook, WorkBookUndoState> {
super.setTemplateTheme(newTheme, compatible);
}
@Override
public void navigate(TRL trl) {
reportComposite.selectCell(trl);
}
}

23
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();
}

27
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<WorkSheet, ElementCasePan
elementCasePane.removeSelectionChangeListener(selectionListener);
}
@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);
}
}

28
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);
}
}

35
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<PolyWorkSheet, PolyElementCase
private PolyComponentsBar polyComponentsBar = new PolyComponentsBar();
private JComponent[] toolBarComponent = null;
private JPanel ployareaPane;
private int resolution = ScreenResolution.getScreenResolution() ;
private int resolution = ScreenResolution.getScreenResolution();
private float time;
public PolyDesigner(PolyWorkSheet report) {
@ -623,7 +625,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
// 在停止编辑的时候,要把编辑器的值赋值给显示器
TemplateBlock block = selection.getValue();
selection.setValue(block);
if (isChooseBlock()){
if (isChooseBlock()) {
((PolyBlockProperPane) this.getEastDownPane()).update();
}
this.removeEditor(selection.getEditor());
@ -1070,4 +1072,33 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
return false;
}
@Override
public void navigate(TRL trl) {
String blockName = trl.unescapeNext();
if (StringUtils.isEmpty(blockName)) {
return;
}
BlockCreator blockCreator = getBlock(blockName);
if (blockCreator == null) {
return;
}
setSelection(blockCreator);
setChooseType(SelectionType.BLOCK);
if (trl.size() > 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;
}
}

29
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);
}
}

Loading…
Cancel
Save