diff --git a/build.gradle b/build.gradle index d58f83f44..ee9bc6278 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ allprojects { group 'com.fr.design' version frDevVersion sourceCompatibility = languageLevelSetting - targetCompatibility = languageLevelSetting + targetCompatibility = languageLevelSetting tasks.withType(JavaCompile) { options.encoding = "UTF-8" @@ -49,8 +49,8 @@ allprojects { idea { module { inheritOutputDirs = false - outputDir = file(outputPath +"/classes") - testOutputDir = file(outputPath +"/test-classes") + outputDir = file(outputPath + "/classes") + testOutputDir = file(outputPath + "/test-classes") languageLevel = new IdeaLanguageLevel(sourceCompatibility) targetBytecodeVersion = targetCompatibility } @@ -68,7 +68,7 @@ allprojects { implementation 'org.swingexplorer:swexpl:2.0.1' implementation 'org.swingexplorer:swag:1.0' implementation 'net.java.dev.jna:jna:5.4.0' - implementation 'org.apache.tomcat:tomcat-catalina:8.5.57' + implementation 'org.apache.tomcat:tomcat-catalina:8.5.69' implementation 'io.socket:socket.io-client:0.7.0' implementation 'com.fr.third:fine-third:' + frVersion implementation 'com.fr.core:fine-core:' + frDevVersion diff --git a/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java b/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java index 5c12ff29c..048f23337 100644 --- a/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java @@ -345,6 +345,17 @@ public abstract class UpdateAction extends ShortCut implements Action { return (JComponent) object; } + public JComponent createToolBarComponentByName(String componentName) { + Object object = this.getValue(componentName); + if (!(object instanceof AbstractButton)) { + UIButton button = null; + button = new UIButton(); + object = initButton(button, componentName); + } + + return (JComponent) object; + } + protected JComponent initButton(UIButton button, String name) { // 添加一个名字作为自动化测试用 button.setName(getName()); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java index 3e08b1399..51a390c82 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java @@ -28,7 +28,7 @@ public class TutorialAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind(createDocKey()); + return CloudCenter.getInstance().acquireUrlByKind(createDocKey(), "http://help.finereport.com"); } // 生成帮助文档 sitecenter key, help.zh_CN.10 diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java index b5bc39e4e..f65610526 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java @@ -25,6 +25,7 @@ import com.fr.design.gui.icombobox.UIComboBoxEditor; import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -39,7 +40,16 @@ import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.server.connection.DBConnectAuth; -import javax.swing.*; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.util.Collections; +import java.util.concurrent.CancellationException; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTree; +import javax.swing.SwingWorker; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.PopupMenuEvent; @@ -50,7 +60,6 @@ import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; -import java.awt.*; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; @@ -70,6 +79,9 @@ import java.util.concurrent.FutureTask; * @since 2012-7-11下午4:49:39 */ public class ChoosePane extends BasicBeanPane implements Refreshable, Previewable, Prepare4DataSourceChange { + + private static final List PENDING_CONTENT = new ArrayList<>(Collections.singletonList(Toolkit.i18nText("Fine-Design_Basic_Loading") + "...")); + private static final double COLUMN_SIZE = 24; /** @@ -91,6 +103,8 @@ public class ChoosePane extends BasicBeanPane implements Refresha private SwingWorker populateWorker; + private SwingWorker, Void> initWorker; + private PopupMenuListener popupMenuListener = new PopupMenuListener() { @Override @@ -213,10 +227,34 @@ public class ChoosePane extends BasicBeanPane implements Refresha @SuppressWarnings("unchecked") protected void initDsNameComboBox() { + if (initWorker != null && !initWorker.isDone()) { + initWorker.cancel(true); + } dsNameComboBox.setRefreshingModel(true); - FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(getHasAuthConnections()); - dsNameComboBox.setModel(dsNameComboBoxModel); - dsNameComboBox.setRefreshingModel(false); + dsNameComboBox.setModel(new FilterableComboBoxModel(PENDING_CONTENT)); + initWorker = new SwingWorker, Void>() { + + @Override + protected List doInBackground() throws Exception { + return getHasAuthConnections(); + } + + @Override + protected void done() { + try { + FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(get()); + String selected = dsNameComboBox.getSelectedItem(); + dsNameComboBox.setModel(dsNameComboBoxModel); + dsNameComboBox.setSelectedItem(selected); + dsNameComboBox.setRefreshingModel(false); + } catch (Exception e) { + if (!(e instanceof CancellationException)) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } + }; + initWorker.execute(); } protected void initComponentsLayout(PreviewLabel previewLabel, int labelSize) { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java index f06d1405b..248d3318c 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java @@ -3,12 +3,19 @@ package com.fr.design.data.datapane.connect; import com.fr.base.BaseUtils; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import javax.swing.*; -import java.awt.*; +import com.fr.log.FineLoggerFactory; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.util.Iterator; +import java.util.concurrent.CancellationException; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JPanel; +import javax.swing.SwingWorker; public abstract class ItemEditableComboBoxPanel extends JPanel { /** @@ -16,6 +23,8 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { */ private static final long serialVersionUID = 1L; + private static final String PENDING = Toolkit.i18nText("Fine-Design_Basic_Loading") + "..."; + protected static final Object EMPTY = new Object() { public String toString() { return ""; @@ -26,6 +35,8 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { protected UIButton editButton; protected UIButton refreshButton; + private SwingWorker, Void> refreshWorker; + public ItemEditableComboBoxPanel() { super(); @@ -75,26 +86,42 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { * 刷新itemComboBox的内容 */ protected void refreshItems() { - // 记录原来选中的Item,重新加载后需要再次选中 - Object lastSelectedItem = itemComboBox.getSelectedItem(); + + if (refreshWorker != null && !refreshWorker.isDone()) { + refreshWorker.cancel(true); + } DefaultComboBoxModel model = ((DefaultComboBoxModel) itemComboBox.getModel()); model.removeAllElements(); // 先加EMPTY,再加items model.addElement(EMPTY); + model.addElement(PENDING); - java.util.Iterator itemIt = items(); - while(itemIt.hasNext()) { - model.addElement(itemIt.next()); - } + refreshWorker = new SwingWorker, Void>() { + @Override + protected Iterator doInBackground() throws Exception { + return items(); + } - // 再次选中之前选中的Item - int idx = model.getIndexOf(lastSelectedItem); - if(idx < 0) { - idx = 0; - } - itemComboBox.setSelectedIndex(idx); + @Override + protected void done() { + try { + Iterator itemIt = get(); + model.removeElement(PENDING); + while(itemIt.hasNext()) { + model.addElement(itemIt.next()); + } + itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() + 1); + } catch (Exception e) { + if (!(e instanceof CancellationException)) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + } + }; + refreshWorker.execute(); } /* diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index c57dfe00d..173da2fbf 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -647,10 +647,12 @@ public class DBTableDataPane extends AbstractTableDataPane { public StrategyConfig find() { StrategyConfig strategyConfig = null; if (getTableData() != null) { - try { - strategyConfig = getTableData().getStrategyConfig() == null ? null : getTableData().getStrategyConfig().clone(); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + strategyConfig = getTableData().getStrategyConfig(); + if (strategyConfig == null) { + //共享数据集 + if (getTableData().isShare()) { + strategyConfig = StrategyConfigHelper.createStrategyConfig(true, false, true); + } } } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java index f119c55cd..82cba758b 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java @@ -23,12 +23,12 @@ import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import java.util.Collection; import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import java.util.Collection; public abstract class JListControlPane extends JControlPane implements ListControlPaneProvider { private static final String LIST_NAME = "JControl_List"; @@ -335,7 +335,7 @@ public abstract class JListControlPane extends JControlPane implements ListContr getHelper().checkButtonEnabled(); } - private class NameableListCellRenderer extends + protected class NameableListCellRenderer extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java index 648cb03f3..f7229136f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java @@ -387,8 +387,6 @@ public abstract class UIControlPane extends JControlPane { contentPane.setBackground(originColor); contentPane.setLayout(new BorderLayout()); titleLabel = new UILabel(title); - Font font = new Font("SimSun", Font.PLAIN, 12); - titleLabel.setFont(font); contentPane.add(titleLabel, BorderLayout.WEST); contentPane.setBorder(new EmptyBorder(5, 14, 6, 0)); diff --git a/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java b/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java index 0efa74cec..4c530c0fc 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java @@ -1,25 +1,22 @@ package com.fr.design.gui.ilist; import com.fr.design.gui.NameInspector; +import com.fr.design.gui.itextfield.UITextField; import com.fr.general.GeneralUtils; import com.fr.general.NameObject; -import com.fr.base.Utils; -import com.fr.design.gui.itextfield.UITextField; - import com.fr.stable.Nameable; import com.fr.stable.StringUtils; import com.fr.stable.core.PropertyChangeAdapter; -import javax.swing.*; +import javax.swing.ListModel; 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; +import java.awt.Component; +import java.awt.Rectangle; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; public class JNameEdList extends UIList implements CellEditorListener { private static final int ICON_WIDTH = 20; @@ -38,6 +35,8 @@ public class JNameEdList extends UIList implements CellEditorListener { */ private String oldName; + private boolean replaceEmptyName = true; + public JNameEdList(ListModel dataModel) { super(dataModel); } @@ -70,6 +69,10 @@ public class JNameEdList extends UIList implements CellEditorListener { return this.editable; } + public void setReplaceEmptyName(boolean replaceEmptyName) { + this.replaceEmptyName = replaceEmptyName; + } + public void setNameShouldNumber(boolean isNameShouldNumber) { this.isNameShouldNumber = isNameShouldNumber; } @@ -301,7 +304,7 @@ public class JNameEdList extends UIList implements CellEditorListener { ListCellEditor editor = getCellEditor(); if (editor != null && editorComp != null) { Object value = editor.getCellEditorValue(); - String name = StringUtils.isBlank(value.toString()) ? oldName : value.toString(); + String name = StringUtils.isBlank(value.toString()) && replaceEmptyName ? oldName : value.toString(); setNameAt(name, editingIndex); removeComp(); doAfterStopEditing(); diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java index 22f6cb246..4a722fc50 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java @@ -73,6 +73,12 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver textField.setValue(defaultValue); } + public UISpinner(double minValue, double maxValue, double dierta, double defaultValue, boolean fillNegativeNumber) { + init(minValue, maxValue, dierta); + textField.setValue(defaultValue); + textField.canFillNegativeNumber(fillNegativeNumber); + } + protected void init(double minValue, double maxValue, double dierta) { this.minValue = minValue; this.maxValue = maxValue; diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java index 9ed906827..85474ca3c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java @@ -1,12 +1,11 @@ package com.fr.design.gui.itextfield; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Toolkit; - import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.PlainDocument; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Toolkit; /** diff --git a/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java b/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java index 237a5659a..0de98c3b5 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java @@ -487,6 +487,7 @@ public class TranslucentBorderSpecialPane extends AbstractBorderPackerPane imple private int ninePointBottom = -1; private static final int MIN_NINE_POINT = 0; + private static final int MIN_GAP_PARALLEL_LINES = 1; private int imgWidth; private int imgHeight; @@ -757,8 +758,8 @@ public class TranslucentBorderSpecialPane extends AbstractBorderPackerPane imple private void onNinePointTopChanged(int value) { if (value < MIN_NINE_POINT) { value = MIN_NINE_POINT; - } else if (value >= imgHeight - ninePointBottom) { - value = imgHeight - ninePointBottom - MIN_NINE_POINT; + } else if (value >= imgHeight - ninePointBottom - MIN_GAP_PARALLEL_LINES) { + value = imgHeight - ninePointBottom - MIN_GAP_PARALLEL_LINES; } this.ninePointTop = value; repaint(); @@ -767,8 +768,8 @@ public class TranslucentBorderSpecialPane extends AbstractBorderPackerPane imple private void onNinePointBottomChanged(int value) { if (value < MIN_NINE_POINT) { value = MIN_NINE_POINT; - } else if (value >= imgHeight - ninePointTop) { - value = imgHeight - ninePointTop - MIN_NINE_POINT; + } else if (value >= imgHeight - ninePointTop - MIN_GAP_PARALLEL_LINES) { + value = imgHeight - ninePointTop - MIN_GAP_PARALLEL_LINES; } this.ninePointBottom = value; repaint(); @@ -777,8 +778,8 @@ public class TranslucentBorderSpecialPane extends AbstractBorderPackerPane imple private void onNinePointLeftChanged(int value) { if (value < MIN_NINE_POINT) { value = MIN_NINE_POINT; - } else if (value >= imgWidth - ninePointRight) { - value = imgWidth - ninePointRight - MIN_NINE_POINT; + } else if (value >= imgWidth - ninePointRight - MIN_GAP_PARALLEL_LINES) { + value = imgWidth - ninePointRight - MIN_GAP_PARALLEL_LINES; } this.ninePointLeft = value; repaint(); @@ -787,8 +788,8 @@ public class TranslucentBorderSpecialPane extends AbstractBorderPackerPane imple private void onNinePointRightChanged(int value) { if (value < MIN_NINE_POINT) { value = MIN_NINE_POINT; - } else if (value >= imgWidth - ninePointLeft) { - value = imgWidth - ninePointLeft - MIN_NINE_POINT; + } else if (value >= imgWidth - ninePointLeft - MIN_GAP_PARALLEL_LINES) { + value = imgWidth - ninePointLeft - MIN_GAP_PARALLEL_LINES; } this.ninePointRight = value; repaint(); diff --git a/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java b/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java index f3367206f..460e838c5 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java @@ -2,6 +2,7 @@ package com.fr.design.javascript; import com.fr.base.BaseFormula; import com.fr.base.Parameter; +import com.fr.base.extension.FileExtension; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; @@ -417,6 +418,9 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane> TEMPLATE_RENAME = new Event>() { + }; private static final String FILE = "file"; private static volatile DesignerFrameFileDealerPane THIS; @@ -690,6 +695,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt boolean success = selectedOperation.rename(fnf, path, newPath); if (success) { + EventDispatcher.fire(TEMPLATE_RENAME, new TwoTuple<>(path, newPath)); HistoryTemplateListCache.getInstance().rename(fnf, path, newPath); DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(fnf.isDirectory(), path, newPath); selectedOperation.refresh(); 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 efeaa6b04..4afe77abd 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 @@ -43,6 +43,7 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.authority.JTemplateAuthorityChecker; import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.mainframe.check.CheckButton; import com.fr.design.mainframe.template.info.TemplateProcessInfo; @@ -69,7 +70,7 @@ import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; -import com.fr.main.impl.WorkBook; +import com.fr.nx.app.designer.utils.CptAndCptxCompatibilityUtil; import com.fr.nx.app.designer.utils.CptCompileUtil; import com.fr.nx.cptx.entry.metadata.CptxMetadata; import com.fr.nx.cptx.utils.CptxFileUtils; @@ -252,6 +253,7 @@ public abstract class JTemplate> } } } + private void stopListenThemeConfig() { if (themeConfigChangeListener != null) { TemplateThemeConfig config = getUsingTemplateThemeConfig(); @@ -1409,7 +1411,7 @@ public abstract class JTemplate> * @return 按钮组 */ public UIButton[] createExtraButtons() { - UIButton[] uiButtons = new UIButton[] { + UIButton[] uiButtons = new UIButton[]{ (UIButton) new CompileAction().createToolBarComponent() }; Set providers = ExtraDesignClassManager.getInstance().getArray(DesignerFrameUpButtonProvider.XML_TAG); @@ -1470,7 +1472,7 @@ public abstract class JTemplate> * 设置新引擎后,有不支持的功能时,设计器中模板的标题需要加上“兼容模式”或者“不支持分页引擎”来提示用户 * */ private String compatibilityTip() { - if (!CptCompileUtil.isNewEngine(this.getTarget(), getEditingFILE().getPath())){ + if (!CptAndCptxCompatibilityUtil.isEngineXEnable(this.getTarget(), getEditingFILE().getPath())){ return StringUtils.EMPTY; } String path = this.getEditingFILE().getPath(); @@ -1576,13 +1578,19 @@ public abstract class JTemplate> } private boolean saveRealFile() throws Exception { - FILE editingFILE = this.getEditingFILE(); - if (editingFILE == null || editingFILE instanceof MemFILE) { + JTemplateAuthorityChecker jTemplateAuthorityChecker = new JTemplateAuthorityChecker(this); + if (jTemplateAuthorityChecker.isAuthority()) { + FILE editingFILE = this.getEditingFILE(); + if (editingFILE == null || editingFILE instanceof MemFILE) { + return false; + } + this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE)); + this.editingFILE = editingFILE; + return true; + } else { + jTemplateAuthorityChecker.showAuthorityFailPromptDialog(); return false; } - this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE)); - this.editingFILE = editingFILE; - return true; } private CallbackSaveWorker saveAs(boolean showLoc) { @@ -1686,8 +1694,7 @@ public abstract class JTemplate> * 2.在这三种情况下:1.cptx文件另存为cpt文件 2.cptx另存为cptx文件 3.设置了新引擎的cpt文件另存为cpt文件, * 因为文件的编译目录改变了,需要重新预编译,因此设置jTemplate的保存状态为false * */ - boolean hasChanged = CptCompileUtil.hasChanged(oldName, this); - if (hasChanged){ + if (CptAndCptxCompatibilityUtil.needRecompile(oldName, this)){ this.saved = false; } result = this.saveRealFile(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/authority/DSColumnAuthorityChecker.java b/designer-base/src/main/java/com/fr/design/mainframe/authority/DSColumnAuthorityChecker.java new file mode 100644 index 000000000..fdab6ea2a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/authority/DSColumnAuthorityChecker.java @@ -0,0 +1,20 @@ +package com.fr.design.mainframe.authority; + +import com.fr.report.cell.cellattr.core.group.DSColumn; +import org.jetbrains.annotations.Nullable; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public class DSColumnAuthorityChecker extends ElementAuthorityChecker { + + @Override + @Nullable + Set getNoAuthDatasetNames(DSColumn dsColumn, Set authDatasetNames) { + if (!authDatasetNames.contains(dsColumn.getDSName())) { + return new HashSet<>(Arrays.asList(dsColumn.getDSName())); + } + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/authority/ElementAuthorityChecker.java b/designer-base/src/main/java/com/fr/design/mainframe/authority/ElementAuthorityChecker.java new file mode 100644 index 000000000..67d0f1da3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/authority/ElementAuthorityChecker.java @@ -0,0 +1,45 @@ +package com.fr.design.mainframe.authority; + +import org.jetbrains.annotations.Nullable; +import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl; + +import java.lang.reflect.Type; +import java.util.Set; + + +public abstract class ElementAuthorityChecker { + + + /** + * @Description 获取越权的数据连接 + * @param: t 待检查的对象 + * @param: authConnectionNames 有权限的数据连接名 + * @return 如果有返回名称,没有返回null + */ + @Nullable + Set getNoAuthConnectionNames(T t, Set authConnectionNames) { + return null; + } + + + /** + * @Description 获取越权的服务器数据集 + * @param: t 待检查的对象 + * @param: authDatasetNames 有权限的服务器数据集名 + * @return 如果有返回名称,没有返回null + */ + @Nullable + Set getNoAuthDatasetNames(T t, Set authDatasetNames) { + return null; + } + + /** + * @Description 要检查对象的className + * @return className + */ + String getCheckClassName() { + ParameterizedTypeImpl parameterizedType = (ParameterizedTypeImpl) this.getClass().getGenericSuperclass(); + Type type = parameterizedType.getActualTypeArguments()[0]; + return type.getTypeName(); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/authority/FormulaAuthorityChecker.java b/designer-base/src/main/java/com/fr/design/mainframe/authority/FormulaAuthorityChecker.java new file mode 100644 index 000000000..d108c18d4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/authority/FormulaAuthorityChecker.java @@ -0,0 +1,27 @@ +package com.fr.design.mainframe.authority; + +import com.fr.base.Formula; +import org.jetbrains.annotations.Nullable; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class FormulaAuthorityChecker extends ElementAuthorityChecker { + private static final Pattern FORMULA_PATTERN = Pattern.compile("^=SQL\\(\"(.+?)\","); + + @Override + @Nullable + public Set getNoAuthConnectionNames(Formula formula, Set authConnectionNames) { + String content = formula.getContent(); + Matcher matcher = FORMULA_PATTERN.matcher(content); + if (matcher.find()) { + if (!authConnectionNames.contains(matcher.group(1))) { + return new HashSet<>(Arrays.asList(matcher.group(1))); + } + } + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/authority/JTemplateAuthorityChecker.java b/designer-base/src/main/java/com/fr/design/mainframe/authority/JTemplateAuthorityChecker.java new file mode 100644 index 000000000..f8b2c8ce6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/authority/JTemplateAuthorityChecker.java @@ -0,0 +1,184 @@ +package com.fr.design.mainframe.authority; + + +import com.fr.design.dialog.FineJOptionPane; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mod.ModClassFilter; +import com.fr.invoke.ClassHelper; + +import com.fr.log.FineLoggerFactory; +import com.fr.rpc.ExceptionHandler; +import com.fr.rpc.RPCInvokerExceptionInfo; +import com.fr.stable.Filter; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.authority.user.UserAuthority; + +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + + +import static javax.swing.JOptionPane.WARNING_MESSAGE; + + +public class JTemplateAuthorityChecker { + JTemplate jTemplate; + Set authConnectionNames; + Set authDatasetNames; + Map checkerMap = new HashMap<>(); + Set authFailConnectionNames = new HashSet<>(); + Set authFailDatasetNames = new HashSet<>(); + + + public JTemplateAuthorityChecker(JTemplate jTemplate) { + long s = System.currentTimeMillis(); + this.jTemplate = jTemplate; + this.initAuthNames(); + this.initChecker(); + FineLoggerFactory.getLogger().info("JTemplateAuthorityChecker init time consume:" + (System.currentTimeMillis() - s)); + } + + private void initAuthNames() { + UserAuthority templateAuthority = WorkContext.getCurrent().get(UserAuthority.class); + Map> authNamesMap = templateAuthority.getAuthServerDataSetAndConnectionNames(); + if (authNamesMap != null) { + //有权限的数据连接名称 + authConnectionNames = authNamesMap.get(UserAuthority.AUTH_CONNECTION_NAMES); + //有权限的数据集名称(模板数据集和服务器数据集) + authDatasetNames = authNamesMap.get(UserAuthority.AUTH_SERVER_DATASET_NAMES); + Iterator iterator = jTemplate.getTarget().getTableDataNameIterator(); + while (iterator.hasNext()) { + String datasetName = iterator.next(); + authDatasetNames.add(datasetName); + } + } + } + + private void initChecker() { + registerChecker(new NameDatabaseConnectionAuthorityChecker()); + registerChecker(new DSColumnAuthorityChecker()); + registerChecker(new FormulaAuthorityChecker()); + registerChecker(new NameTableDataAuthorityChecker()); + } + + private void registerChecker(ElementAuthorityChecker checker) { + checkerMap.put(checker.getCheckClassName(), checker); + } + + + public boolean isAuthority() { + long s = System.currentTimeMillis(); + //遍历模板对象,根据checkerMap.keySet()把感兴趣的对象找出来 + Map> targetObjects = ClassHelper.searchObject(jTemplate.getTarget(), checkerMap.keySet(), ClassFilter.getInstance()); + + //找到对应的checker,对对象进行检查 + for (String name : targetObjects.keySet()) { + ElementAuthorityChecker checker = checkerMap.get(name); + for (Object object : targetObjects.get(name)) { + if (authConnectionNames != null) { + Set noAuthName = checker.getNoAuthConnectionNames(object, authConnectionNames); + if (noAuthName != null) { + authFailConnectionNames.addAll(noAuthName); + } + } + if (authDatasetNames != null) { + Set noAuthName = checker.getNoAuthDatasetNames(object, authDatasetNames); + if (noAuthName != null) { + authFailDatasetNames.addAll(noAuthName); + } + } + } + } + + FineLoggerFactory.getLogger().info("JTemplateAuthorityChecker check time consume:" + (System.currentTimeMillis() - s)); + return authFailConnectionNames.size() == 0 && authFailDatasetNames.size() == 0; + } + + public void showAuthorityFailPromptDialog() { + StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(Toolkit.i18nText("Fine-Design-Basic_Save_Failure")); + stringBuffer.append("\n"); + stringBuffer.append(getPromptInfo(authFailDatasetNames, + Toolkit.i18nText("Fine-Design_Template_Authority_Check_Server_Dataset_Authority"))); + stringBuffer.append(getPromptInfo(authFailConnectionNames, + Toolkit.i18nText("Fine-Design_Template_Authority_Check_Data_Connection_Authority"))); + FineJOptionPane.showMessageDialog( + DesignerContext.getDesignerFrame(), + stringBuffer.toString(), + Toolkit.i18nText("Fine-Design_Basic_Alert"), + WARNING_MESSAGE); + } + + private String getPromptInfo(Set authFailNames, String message) { + StringBuffer stringBuffer = new StringBuffer(); + if (authFailNames.size() > 0) { + stringBuffer.append(Toolkit.i18nText("Fine-Design_Template_Authority_Check_Current_Operator_Miss")); + stringBuffer.append(authFailNames.size()); + stringBuffer.append(Toolkit.i18nText("Fine-Design_Report_Ge")); + stringBuffer.append(message); + stringBuffer.append("\n"); + stringBuffer.append(getNoAuthNameSequence(authFailNames)); + } + return stringBuffer.toString(); + } + + private String getNoAuthNameSequence(Set names) { + StringBuffer stringBuffer = new StringBuffer(); + int showMaxCount = 3; + int count = 0; + for (String name : names) { + if (count == showMaxCount) { + stringBuffer.append(Toolkit.i18nText("Fine-Design_Template_Authority_Check_Etc")); + break; + } + stringBuffer.append(name); + if (count != names.size() - 1 && count != showMaxCount - 1) { + stringBuffer.append(";"); + } + count++; + } + stringBuffer.append("\n"); + return stringBuffer.toString(); + } + + static class ClassFilter implements Filter { + + private static final Set FILTER_SET = new HashSet<>(); + private static final Set START_WITH_SET = new HashSet<>(); + private static final Filter INSTANCE = new ModClassFilter(); + + public static Filter getInstance() { + return INSTANCE; + } + + static { + FILTER_SET.add("java.awt.image.BufferedImage"); + FILTER_SET.add("sun.awt.AppContext"); + FILTER_SET.add("com.fr.poly.creator.ECBlockCreator"); + FILTER_SET.add("io.netty.channel.nio.SelectedSelectionKeySet"); + FILTER_SET.add("com.fr.form.ui.ElementCaseImage"); + FILTER_SET.add("this$0"); + START_WITH_SET.add("com.fr.design"); + } + + @Override + public boolean accept(String s) { + if (FILTER_SET.contains(s)) { + return true; + } + for (String start : START_WITH_SET) { + if (s.startsWith(start)) { + return true; + } + } + return false; + } + } +} + diff --git a/designer-base/src/main/java/com/fr/design/mainframe/authority/NameDatabaseConnectionAuthorityChecker.java b/designer-base/src/main/java/com/fr/design/mainframe/authority/NameDatabaseConnectionAuthorityChecker.java new file mode 100644 index 000000000..96bc0b8c5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/authority/NameDatabaseConnectionAuthorityChecker.java @@ -0,0 +1,22 @@ +package com.fr.design.mainframe.authority; + +import com.fr.data.impl.NameDatabaseConnection; +import org.jetbrains.annotations.Nullable; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; + +public class NameDatabaseConnectionAuthorityChecker extends ElementAuthorityChecker { + @Override + @Nullable + Set getNoAuthConnectionNames(NameDatabaseConnection nameDatabaseConnection, Set authConnectionNames) { + String name = nameDatabaseConnection.getName(); + if (!authConnectionNames.contains(name)) { + return new HashSet<>(Arrays.asList(name)); + } + return null; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/authority/NameTableDataAuthorityChecker.java b/designer-base/src/main/java/com/fr/design/mainframe/authority/NameTableDataAuthorityChecker.java new file mode 100644 index 000000000..13e730085 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/authority/NameTableDataAuthorityChecker.java @@ -0,0 +1,19 @@ +package com.fr.design.mainframe.authority; + +import com.fr.data.impl.NameTableData; +import org.jetbrains.annotations.Nullable; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public class NameTableDataAuthorityChecker extends ElementAuthorityChecker { + @Override + @Nullable + Set getNoAuthDatasetNames(NameTableData nameTableData, Set authDatasetNames) { + if (!authDatasetNames.contains(nameTableData.getName())) { + return new HashSet<>(Arrays.asList(nameTableData.getName())); + } + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java index 19885763c..c302cf1ad 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java @@ -48,9 +48,6 @@ public abstract class TemplateThemePreviewPane extends int height = getHeight(); try { - // 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image, - // 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0) - // 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图 image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = image.createGraphics(); // 创建一个支持透明背景的buffer image @@ -58,8 +55,6 @@ public abstract class TemplateThemePreviewPane extends g2d.dispose(); g2d = image.createGraphics(); - g2d.fillRect(0, 0, width, height); - g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.clipRect(0, 0, width, height); @@ -80,6 +75,9 @@ public abstract class TemplateThemePreviewPane extends @Override public void paintComponent(Graphics g) { g.clearRect(0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT); + // 添加个默认白色,否则因为上面的clearRect导致无背景时会出现黑色 + g.setColor(Color.WHITE); + g.fillRect(0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT); paintBackground((Graphics2D) g); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java index 01a13ea98..9544b2563 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java @@ -237,6 +237,9 @@ public abstract class TemplateThemeProfilePane extends double[] rowSize = new double[]{p, p, p}; double[] columnSize = {p, p}; + JPanel colorListContainerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + colorListContainerPane.add(colorListPane, BorderLayout.WEST); + JPanel previewLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); previewLabelPane.add(LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Preview_Label")), BorderLayout.NORTH); @@ -244,7 +247,7 @@ public abstract class TemplateThemeProfilePane extends tipLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); JPanel content = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ - {LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Edit_Label")), colorListPane}, + {LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Edit_Label")), colorListContainerPane}, {null, tipLabel}, {previewLabelPane, extendedContainer}, }, @@ -313,7 +316,6 @@ public abstract class TemplateThemeProfilePane extends colorListExtendedPane.populate(colors); FineColorManager.FineColorReplaceByColorScheme replaceByColorScheme = new FineColorManager.FineColorReplaceByColorScheme(colors); T theme = updateBean(); - FineColorFlushUtils.replaceCacheObject(theme, replaceByColorScheme); FineColorManager.traverse(theme, replaceByColorScheme); populateBean4CustomEditors(theme); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index d8e5b4a57..866c2fabe 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -40,6 +40,7 @@ import com.fr.design.actions.server.GlobalParameterAction; import com.fr.design.actions.server.GlobalTableDataAction; import com.fr.design.actions.server.PlatformManagerAction; import com.fr.design.actions.server.PluginManagerAction; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.file.NewTemplatePane; import com.fr.design.fun.MenuHandler; import com.fr.design.fun.OemProcessor; @@ -491,10 +492,12 @@ public abstract class ToolBarMenuDock { if (!DesignerMode.isAuthorityEditing()) { addPluginManagerAction(menuDef); - menuDef.addShortCut( - new FunctionManagerAction(), - new GlobalParameterAction() - ); + menuDef.addShortCut(new FunctionManagerAction()); + + if (!DesignModeContext.isDuchampMode()) { + menuDef.addShortCut(new GlobalParameterAction()); + } + } diff --git a/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java b/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java index 8c7ed5ac5..90d6accf6 100644 --- a/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java +++ b/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java @@ -17,15 +17,16 @@ import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; import com.teamdev.jxbrowser.chromium.events.ScriptContextListener; import com.teamdev.jxbrowser.chromium.swing.BrowserView; +import com.teamdev.jxbrowser.event.Observer; import javax.swing.JDialog; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import java.util.Map; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.Map; /** * @author richie @@ -157,6 +158,34 @@ public class ModernUIPane extends BasicPane { return null; } + public void disposeBrowser() { + + if(browser != null) { + browser.dispose(); + browser = null; + } + + } + + public void clearCache() { + if (browser != null) { + browser.getCacheStorage().clearCache(); + } + } + + public void executeJavaScript(String javaScript) { + if (browser != null) { + browser.executeJavaScript(javaScript); + } + } + + public JSValue executeJavaScriptAndReturnValue(String javaScript) { + if (browser != null) { + return browser.executeJavaScriptAndReturnValue(javaScript); + } + return null; + } + public static class Builder implements BuilderDiff { private ModernUIPane pane; @@ -293,6 +322,12 @@ public class ModernUIPane extends BasicPane { return this; } + @Override + public Builder prepareForV7(Class event, Observer listener) { + // do nothing + return this; + } + public ModernUIPane build() { return pane; } diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java b/designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java index 33c817c94..9e6168514 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java +++ b/designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java @@ -4,6 +4,7 @@ import com.fr.design.ui.ModernUIPane; import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; import com.teamdev.jxbrowser.chromium.events.LoadListener; import com.teamdev.jxbrowser.chromium.events.ScriptContextListener; +import com.teamdev.jxbrowser.event.Observer; /** * 封装jxbrwoser v6/v7的构建方式的差异 @@ -20,5 +21,6 @@ public interface BuilderDiff { ModernUIPane.Builder prepareForV7(InjectJsCallback callback); + ModernUIPane.Builder prepareForV7(Class event, Observer listener); } diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java index 5ae56627e..68b8950f7 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java @@ -11,6 +11,17 @@ import com.fr.stable.os.OperatingSystem; public class ModernUIPaneFactory { public static ModernUIPane.Builder modernUIPaneBuilder() { + + if (isV7()) { + return new NewModernUIPane.Builder<>(); + } else { + return new ModernUIPane.Builder<>(); + } + + } + + public static boolean isV7() { + // 7.15的class不存在时 走老版本 boolean hasJxBrowserV7_15 = true; try { @@ -18,10 +29,8 @@ public class ModernUIPaneFactory { } catch (ClassNotFoundException e) { hasJxBrowserV7_15 = false; } - if (OperatingSystem.isWindows() && hasJxBrowserV7_15) { - return new NewModernUIPane.Builder<>(); - } else { - return new ModernUIPane.Builder<>(); - } + + return OperatingSystem.isWindows() && hasJxBrowserV7_15; + } } diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java b/designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java index 33747d3f1..d755d4e05 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java +++ b/designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java @@ -15,6 +15,7 @@ import com.teamdev.jxbrowser.chromium.events.ScriptContextListener; import com.teamdev.jxbrowser.engine.Engine; import com.teamdev.jxbrowser.engine.EngineOptions; import com.teamdev.jxbrowser.engine.RenderingMode; +import com.teamdev.jxbrowser.event.Observer; import com.teamdev.jxbrowser.js.JsObject; import com.teamdev.jxbrowser.net.Scheme; import com.teamdev.jxbrowser.view.swing.BrowserView; @@ -80,30 +81,33 @@ public class NewModernUIPane extends ModernUIPane { private void showDebuggerDialog() { JDialog dialog = new JDialog(SwingUtilities.getWindowAncestor(this)); - Engine engine = Engine.newInstance( - EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED) - .addSwitch("--disable-google-traffic") - .remoteDebuggingPort(9222).build()); - Browser debugger = engine.newBrowser(); + + Browser debugger = browser.engine().newBrowser(); BrowserView debuggerView = BrowserView.newInstance(debugger); dialog.add(debuggerView, BorderLayout.CENTER); dialog.setSize(new Dimension(800, 400)); GUICoreUtils.centerWindow(dialog); dialog.setVisible(true); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + browser.devTools().remoteDebuggingUrl().ifPresent(url -> { debugger.navigation().loadUrl(url); }); } private void initializeBrowser() { - EngineOptions options; + EngineOptions.Builder builder; if (scheme != null && requestCallback != null) { - options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").addScheme(scheme, requestCallback).build(); - } else { - options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").build(); + builder = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").addScheme(scheme, requestCallback); + } else { + builder = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic"); + } + + if (DesignerEnvManager.getEnvManager().isOpenDebug()) { + builder.remoteDebuggingPort(9222); } - Engine engine = Engine.newInstance(options); + + Engine engine = Engine.newInstance(builder.build()); browser = engine.newBrowser(); // 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的 @@ -161,6 +165,29 @@ public class NewModernUIPane extends ModernUIPane { return null; } + public void disposeBrowser() { + + if (browser != null) { + browser.close(); + browser = null; + } + + } + + public void clearCache() { + if (browser != null) { + browser.engine().httpCache().clear(); + } + } + + public void executeJavaScript(String javaScript) { + if (browser != null) { + browser.mainFrame().ifPresent(frame -> { + frame.executeJavaScript(javaScript); + }); + } + } + public static class Builder extends ModernUIPane.Builder { private NewModernUIPane pane = new NewModernUIPane<>(); @@ -191,7 +218,7 @@ public class NewModernUIPane extends ModernUIPane { @Override public NewModernUIPane.Builder withURL(final String url) { pane.scheme = Scheme.of("file"); - pane.requestCallback = new NxComplexInterceptRequestCallback(null); + pane.requestCallback = new NxComplexInterceptRequestCallback(null); pane.browser.navigation().loadUrl(url); return this; } @@ -301,6 +328,14 @@ public class NewModernUIPane extends ModernUIPane { return prepare(callback); } + @Override + public ModernUIPane.Builder prepareForV7(Class event, Observer listener) { + + pane.browser.navigation().on(event, listener); + + return this; + } + @Override public NewModernUIPane build() { return pane; diff --git a/designer-base/src/main/java/com/fr/design/utils/gui/AdjustWorkBookDefaultStyleUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/AdjustWorkBookDefaultStyleUtils.java new file mode 100644 index 000000000..abae997e3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/utils/gui/AdjustWorkBookDefaultStyleUtils.java @@ -0,0 +1,46 @@ +package com.fr.design.utils.gui; + +import com.fr.base.Style; +import com.fr.base.background.ColorBackground; +import com.fr.design.base.mode.DesignModeContext; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.FloatElement; + +import java.awt.Color; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/9/6 + */ +public class AdjustWorkBookDefaultStyleUtils { + + private static final Color TEMPLATE_BACKGROUND = new Color(16, 11, 43); + private static final Color CELL_ELEMENT_BORDER = new Color(110, 110, 110); + + public static void adjustCellElement(CellElement cellElement) { + if (DesignModeContext.isDuchampMode()) { + Style style = cellElement.getStyle(); + style = style.deriveFRFont(style.getFRFont().applyForeground(Color.WHITE)); + style = style.deriveBorder(0, CELL_ELEMENT_BORDER, + 0, CELL_ELEMENT_BORDER, + 0, CELL_ELEMENT_BORDER, + 0, CELL_ELEMENT_BORDER); + cellElement.setStyle(style); + } + } + + public static void adjustFloatElement(FloatElement floatElement) { + if (DesignModeContext.isDuchampMode()) { + Style style = floatElement.getStyle(); + style = style.deriveBackground(ColorBackground.getInstance(TEMPLATE_BACKGROUND)); + style = style.deriveFRFont(style.getFRFont().applyForeground(Color.WHITE)); + floatElement.setStyle(style); + } + } + + public static Color adjustBack(Color color) { + return DesignModeContext.isDuchampMode() ? TEMPLATE_BACKGROUND : color; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java index a89e367d6..ac7578631 100644 --- a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java @@ -38,7 +38,6 @@ import com.fr.stable.Constants; import com.fr.stable.OperatingSystem; import com.fr.stable.StringUtils; -import java.awt.Container; import javax.swing.AbstractButton; import javax.swing.Action; import javax.swing.BorderFactory; @@ -67,10 +66,13 @@ import javax.swing.tree.TreePath; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; +import java.awt.Container; import java.awt.Cursor; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; import java.awt.GridLayout; import java.awt.Image; import java.awt.Point; @@ -82,8 +84,6 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.image.BufferedImage; import java.awt.image.ImageObserver; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -176,7 +176,7 @@ public final class GUICoreUtils { if (style.getBackground() instanceof ColorBackground) { textField.setBackground(((ColorBackground) style.getBackground()).getColor()); } else { - textField.setBackground(Color.WHITE); + textField.setBackground(AdjustWorkBookDefaultStyleUtils.adjustBack(Color.WHITE)); } } diff --git a/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptAndCptxCompatibilityUtil.java b/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptAndCptxCompatibilityUtil.java new file mode 100644 index 000000000..0b1a65657 --- /dev/null +++ b/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptAndCptxCompatibilityUtil.java @@ -0,0 +1,88 @@ +package com.fr.nx.app.designer.utils; + +import com.fr.base.extension.FileExtension; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILE; +import com.fr.main.TemplateWorkBook; +import com.fr.report.report.Report; +import com.fr.report.stable.LayerReportAttr; +import com.fr.report.worksheet.WorkSheet; + +/** + * @author fly.li + * @version 10.0 + * Created on 2021/09/12 + */ +public class CptAndCptxCompatibilityUtil { + + /** + * 判断是否需要重新编译 + **/ + public static boolean needRecompile(String oldName, JTemplate jTemplate){ + FILE editingFILE = jTemplate.getEditingFILE(); + String path = editingFILE.getPath(); + //只有在旧文件是cptx文件并且新文件是cpt文件时才会改变报表引擎属性 + boolean isCptxConvertToCpt = FileExtension.CPTX.matchExtension(oldName) && FileExtension.CPT.matchExtension(path); + if (isCptxConvertToCpt && !setFrEngineAttr(jTemplate)){ + isCptxConvertToCpt = false; + } + return (isCptxConvertToCpt || isSaveAs(jTemplate, oldName, path)); + } + + /** + * 判断是不是cptx模板或者开启了的新引擎的cpt模板的另存为操作 + **/ + private static boolean isSaveAs(JTemplate jTemplate, String oldName, String newName){ + return isEngineXEnable(jTemplate.getTarget(), newName) && ((FileExtension.CPTX.matchExtension(oldName) && FileExtension.CPTX.matchExtension(newName)) || (FileExtension.CPT.matchExtension(oldName) && FileExtension.CPT.matchExtension(newName))); + } + + /** + * cptx另存为cpt需要修改报表引擎属性 + **/ + private static boolean setFrEngineAttr(JTemplate jTemplate){ + WorkSheet workSheet = gainWorkSheet(jTemplate.getTarget()); + if (workSheet == null){ + return false; + }else { + LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr(); + if (layerReportAttr == null){ + layerReportAttr = new LayerReportAttr(); + workSheet.setLayerReportAttr(layerReportAttr); + } + layerReportAttr.setClientPaging(true); + layerReportAttr.setEngineState(0); + return true; + } + } + + /** + * 是否启用了新引擎的判断 + * cptx自动走新引擎(非兼容模式),cpt需要进行设置 + * */ + public static boolean isEngineXEnable(Object workBook, String fileName){ + WorkSheet workSheet = gainWorkSheet(workBook); + LayerReportAttr layerReportAttr = gainLayerReportAttr(workSheet); + return isEngineXEnable(layerReportAttr, fileName); + } + + private static LayerReportAttr gainLayerReportAttr(WorkSheet workSheet){ + if (workSheet != null){ + LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr(); + return layerReportAttr; + } else { + return null; + } + } + + private static WorkSheet gainWorkSheet(Object workBook){ + if (workBook == null || !(workBook instanceof TemplateWorkBook)){ + return null; + } + Report report = ((TemplateWorkBook) workBook).getReport(0); + return report instanceof WorkSheet ? (WorkSheet)report : null; + } + + private static boolean isEngineXEnable(LayerReportAttr layerReportAttr, String fileName){ + return (layerReportAttr!= null && layerReportAttr.isClientPaging() && layerReportAttr.getEngineState() == LayerReportAttr.ENGINE_X) || FileExtension.CPTX.matchExtension(fileName); + } +} diff --git a/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java b/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java index 7067789a4..36c184670 100644 --- a/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java +++ b/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java @@ -6,7 +6,6 @@ import com.fr.file.FILE; import com.fr.file.FileNodeFILE; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; -import com.fr.main.TemplateWorkBook; import com.fr.main.impl.WorkBook; import com.fr.nx.app.designer.cptx.io.DesignReadWritableProvider; import com.fr.nx.app.designer.monitor.DesignerMetricRecorder; @@ -25,9 +24,6 @@ import com.fr.nx.cptx.utils.CptxFileUtils; import com.fr.nx.data.layer.LayerItem; import com.fr.nx.data.layer.LayerProps; import com.fr.nx.template.compile.CompiledReport; -import com.fr.report.report.Report; -import com.fr.report.stable.LayerReportAttr; -import com.fr.report.worksheet.WorkSheet; import java.io.OutputStream; @@ -39,15 +35,18 @@ public class CptCompileUtil { } FILE file = jtemplate.getEditingFILE(); String path = file.getPath(); - WorkBook workbook = (WorkBook) jtemplate.getTarget(); + Object target = jtemplate.getTarget(); /* * 如果是cpt并且引擎设置正确,执行预编译,如果是cptx文件也执行预编译。在JStreamWork中,保存和另存为流程都进行了重新编译。 * 但是由于之前的DefaultTemplateResource.saveTemplate的原因导致JStreamWork::saveFile()不能执行--cptx的保存不能进行预编译, * 应该是流程的误改动,这里改回来,保存时仍然执行预编译。 + * 预编译本不应该受引擎模式的影响,但是cpt文件在设置为新引擎后是需要进行编译的 * */ - if (!isNewEngine(workbook, path)){ + + if (!CptAndCptxCompatibilityUtil.isEngineXEnable(target, path)){ return; } + WorkBook workbook = (WorkBook) jtemplate.getTarget(); TransformResultInfo resultInfo = compile0(workbook, file); unSupportLog(resultInfo); @@ -140,70 +139,6 @@ public class CptCompileUtil { || ComparatorUtils.equals(TransformResult.UNSUPPORT, result); } - /* - * 该另存为流程会改变文件内容,现在作为兼容的流程,以后可以随时删除该流程 - * */ - public static boolean hasChanged(String oldName, JTemplate jTemplate){ - FILE editingFILE = jTemplate.getEditingFILE(); - String path = editingFILE.getPath(); - //只有在旧文件是cptx文件并且新文件是cpt文件时才会改变报表引擎属性 - boolean isChange = oldName.endsWith(".cptx") && path.endsWith(".cpt"); - if (isChange && !changeFrEngineAttr(jTemplate)){ - isChange = false; - } - //合并JStreamWork中另存为流程,cptx的另存为也需要重新预编译 - return (isChange || isSaveAs(jTemplate, oldName, path)); - } - - //cptx和设置了新引擎的cpt的另存也需要进行预编译 - private static boolean isSaveAs(JTemplate jTemplate, String oldName, String newName){ - return isNewEngine(jTemplate.getTarget(), newName) && ((FileExtension.CPTX.matchExtension(oldName) && FileExtension.CPTX.matchExtension(newName)) || (FileExtension.CPT.matchExtension(oldName) && FileExtension.CPT.matchExtension(newName))); - } - - private static boolean changeFrEngineAttr(JTemplate jTemplate){ - WorkSheet workSheet = gainWorkSheet(jTemplate); - if (workSheet == null){ - return false; - }else { - LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr(); - if (layerReportAttr == null){ - layerReportAttr = new LayerReportAttr(); - workSheet.setLayerReportAttr(layerReportAttr); - } - layerReportAttr.setClientPaging(true); - layerReportAttr.setNewEngine(true); - return true; - } - } - - - public static boolean isNewEngine(Object workBook, String fileName){ - WorkSheet workSheet = gainWorkSheet(workBook); - LayerReportAttr layerReportAttr = gainLayerReportAttr(workSheet); - return isNewEngine(layerReportAttr, fileName); - } - - private static LayerReportAttr gainLayerReportAttr(WorkSheet workSheet){ - if (workSheet != null){ - LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr(); - return layerReportAttr; - } else { - return null; - } - } - - private static WorkSheet gainWorkSheet(Object workBook){ - if (workBook == null || !(workBook instanceof TemplateWorkBook)){ - return null; - } - Report report = ((TemplateWorkBook) workBook).getReport(0); - return report instanceof WorkSheet ? (WorkSheet)report : null; - } - - private static boolean isNewEngine(LayerReportAttr layerReportAttr, String fileName){ - return (layerReportAttr!= null && layerReportAttr.isClientPaging() && layerReportAttr.isNewEngine()) || FileExtension.CPTX.matchExtension(fileName); - } - private static void unSupportLog(TransformResultInfo transformResultInfo){ TransformResult result = transformResultInfo.getResult(); //这里只打印模板转换不支持的信息,没有打印模板转换失败的信息 @@ -212,5 +147,7 @@ public class CptCompileUtil { } } - + private static boolean isUnSupportFileType(String path){ + return FileExtension.CPT.matchExtension(path) || FileExtension.CPTX.matchExtension(path); + } } diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java index 433c7dfd0..99d048a81 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java @@ -4,16 +4,25 @@ import com.fr.base.ChartColorMatching; import com.fr.base.ChartPreStyleConfig; import com.fr.base.Utils; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.ShortCut4JControlPane; +import com.fr.design.gui.ilist.JNameEdList; +import com.fr.design.i18n.Toolkit; import com.fr.design.menu.ShortCut; +import com.fr.general.ComparatorUtils; import com.fr.general.NameObject; import com.fr.stable.Nameable; +import com.fr.stable.StringUtils; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; +import java.util.List; /** * @author Bjorn @@ -22,6 +31,42 @@ import java.util.Iterator; */ public class ChartPreStyleListPane extends JListControlPane { + public ChartPreStyleListPane() { + super(); + addModNameActionListener((int index, String oldName, String newName) -> { + if (ComparatorUtils.equals(oldName, newName)) { + return; + } + String[] allNames = nameableList.getAllNames(); + allNames[index] = StringUtils.EMPTY; + if (StringUtils.isEmpty(newName)) { + showTipDialog(Toolkit.i18nText("Fine-Design_Chart_Fill_Style_Empty_Name_Tip")); + nameableList.setNameAt(oldName, index); + return; + } + if (isNameRepeated(new List[]{Arrays.asList(allNames)}, newName)) { + showTipDialog(Toolkit.i18nText("Fine-Design_Chart_Fill_Style_Exist_Name_Tip", newName)); + nameableList.setNameAt(oldName, index); + return; + } + populateSelectedValue(); + }); + } + + private void showTipDialog(String content) { + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ChartPreStyleListPane.this), + content, + Toolkit.i18nText("Fine-Design_Basic_Alert"), + JOptionPane.WARNING_MESSAGE); + } + + @Override + protected JNameEdList createJNameList() { + JNameEdList jNameList = super.createJNameList(); + jNameList.setReplaceEmptyName(false); + return jNameList; + } + /** * 创建有名字的creator * @@ -102,4 +147,4 @@ public class ChartPreStyleListPane extends JListControlPane { this.shortCut.setEnabled(nameableList.getModel().getSize() > 1); } } -} +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java index 8aab51b3f..82a62f02c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java @@ -44,6 +44,9 @@ public class VanChartCustomInteractivePane extends VanChartInteractivePane { @Override protected void updateHyperlink(Plot plot){ + if (hyperlinkPane == null) { + return; + } hyperlinkPane.updateBean(chart); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java index c97f3a8ec..78be16ad5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java @@ -685,7 +685,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { } protected void updateHyperlink(Plot plot) { - superLink.update(plot); + if (superLink != null) { + superLink.update(plot); + } } private void updateChartTools(VanChart chart) { @@ -734,6 +736,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { private void updateAutoRefresh(VanChart chart) { + if (autoRefreshPane == null) { + return; + } RefreshMoreLabel refreshMoreLabel = chart.getRefreshMoreLabel(); if (refreshMoreLabel == null) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java index a6ede0df7..1d49fd834 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java @@ -35,6 +35,9 @@ public class VanChartMapInteractivePane extends VanChartInteractivePaneWithMapZo @Override protected void updateHyperlink(Plot plot) { + if (hyperlinkPane == null) { + return; + } hyperlinkPane.updateBean(plot); } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java index f10b877e2..438699b86 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java @@ -1,7 +1,12 @@ package com.fr.design.designer.beans; import com.fr.design.beans.GroupModel; +import com.fr.design.designer.beans.adapters.layout.DefaultDesignerBaseOperate; +import com.fr.design.designer.beans.adapters.layout.DesignerBaseOperate; +import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.treeview.DefaultXCreatorTreeCellRender; +import com.fr.design.designer.treeview.XCreatorTreeCellRender; /** * 该接口是LayoutManager的BeanInfo类。标准Java平台没有提供布局管理器的BeanInfo类, @@ -50,11 +55,11 @@ public interface LayoutAdapter { * @param creator 被添加的新组件 * @param x 添加的位置x,该位置是相对于container的 * @param y 添加的位置y,该位置是相对于container的 - * @param accept 是否添加新组件 + * @param accept 是否添加新组件 * @return 是否添加成功,成功返回true,否则false */ boolean addBean(XCreator creator, int x, int y, boolean accept); - + /** * 返回该布局管理适配器的Painter,为容器提供放置位置的标识。 */ @@ -104,4 +109,36 @@ public interface LayoutAdapter { * @param initHeight 组件之前高度 */ void removeBean(XCreator creator, int initWidth, int initHeight); + + /** + * 获取布局下控件树render + * @param creator + * @return + */ + default XCreatorTreeCellRender getLayoutTreeCellRender(XCreator creator) { + return new DefaultXCreatorTreeCellRender(creator); + } + + /** + * 获取布局下支持的设计器基本操作 + * @return + */ + default DesignerBaseOperate getDesignerBaseOperate() { + return new DefaultDesignerBaseOperate(); + } + + /** + * 是否支持修改间距 + * @return + */ + default boolean supportModifyInsert() { + return true; + } + + void dragStart(XCreator xCreator, SelectionModel selectionModel); + + default void dragOver(XCreator xCreator, SelectionModel selectionModel, int x, int y) { + + }; + } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java index 94c84a87d..7e1329b93 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java @@ -2,7 +2,6 @@ package com.fr.design.designer.beans.actions; import com.fr.design.base.mode.DesignModeContext; -import com.fr.design.designer.beans.actions.behavior.ComponentEnable; import com.fr.design.designer.beans.actions.behavior.CutableEnable; import com.fr.design.mainframe.FormDesigner; diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/PasteAction.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/PasteAction.java index ef35097b2..00e229e68 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/actions/PasteAction.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/PasteAction.java @@ -1,6 +1,7 @@ package com.fr.design.designer.beans.actions; import com.fr.design.base.mode.DesignModeContext; +import com.fr.design.designer.beans.actions.behavior.PasteEnable; import com.fr.design.mainframe.FormDesigner; import javax.swing.KeyStroke; @@ -15,6 +16,7 @@ public class PasteAction extends FormWidgetEditAction { this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Edit_Paste")); this.setMnemonic('P'); this.setSmallIcon("/com/fr/design/images/m_edit/paste"); + this.setUpdateBehavior(new PasteEnable()); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER)); } @@ -22,10 +24,5 @@ public class PasteAction extends FormWidgetEditAction { public boolean executeActionReturnUndoRecordNeeded() { return DesignModeContext.doPaste(getEditingComponent()); } - - @Override - public void update() { - this.setEnabled(true); - } - + } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/PasteEnable.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/PasteEnable.java new file mode 100644 index 000000000..47c5c5af1 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/PasteEnable.java @@ -0,0 +1,16 @@ +package com.fr.design.designer.beans.actions.behavior; + +import com.fr.design.designer.beans.actions.FormWidgetEditAction; +import com.fr.design.mainframe.FormDesigner; + +public class PasteEnable implements UpdateBehavior { + @Override + public void doUpdate(FormWidgetEditAction action) { + FormDesigner designer = action.getEditingComponent(); + if (designer == null) { + action.setEnabled(false); + return; + } + action.setEnabled(designer.isCurrentComponentPastable()); + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/component/CompositeComponentAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/component/CompositeComponentAdapter.java index 5fdc8f3de..cb7a7a620 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/component/CompositeComponentAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/component/CompositeComponentAdapter.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; import java.beans.IntrospectionException; import java.util.ArrayList; import java.util.Collections; @@ -64,13 +65,15 @@ public class CompositeComponentAdapter implements ComponentAdapter { @Override public void paintComponentMascot(Graphics g) { - //自适应交叉点渲染有点问题,拖拽的控件设置成半透明 - Graphics2D g2d = (Graphics2D) g; - AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER,.5f); - g2d.setComposite(composite); - xCreator.paint(g2d); + //自适应交叉点渲染有点问题,拖拽的控件设置成半透明 + Graphics2D g2d = (Graphics2D) g; + AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f); + g2d.setComposite(composite); + BufferedImage im = new BufferedImage(xCreator.getWidth(), xCreator.getHeight(), BufferedImage.TYPE_INT_ARGB); + xCreator.paint(im.getGraphics()); + g.drawImage(im, 0, 0, xCreator.initEditorSize().width - 1, xCreator.initEditorSize().height - 1, null); g.setColor(XCreatorConstants.RESIZE_BOX_BORDER_COLOR); - g.drawRect(0, 0, xCreator.getWidth() - 1, xCreator.getHeight() - 1); + g.drawRect(0, 0, xCreator.initEditorSize().width - 1, xCreator.initEditorSize().height - 1); } @Override diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java index e9851a7e8..98b6c8855 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java @@ -4,6 +4,7 @@ import com.fr.design.beans.GroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.LayoutAdapter; +import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.painters.NullPainter; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; @@ -203,4 +204,11 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter { public XLayoutContainer getContainer() { return this.container; } + + public void dragStart(XCreator xCreator, SelectionModel selectionModel){ + selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight()); + selectionModel.setSelectedCreator(container); + } + + } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/DefaultDesignerBaseOperate.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/DefaultDesignerBaseOperate.java new file mode 100644 index 000000000..f3ec95939 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/DefaultDesignerBaseOperate.java @@ -0,0 +1,23 @@ +package com.fr.design.designer.beans.adapters.layout; + +public class DefaultDesignerBaseOperate implements DesignerBaseOperate{ + @Override + public boolean supportCopyAction() { + return true; + } + + @Override + public boolean supportCutAction() { + return true; + } + + @Override + public boolean supportPasteAction() { + return true; + } + + @Override + public boolean supportDeleteAction() { + return true; + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/DesignerBaseOperate.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/DesignerBaseOperate.java new file mode 100644 index 000000000..410daf8b5 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/DesignerBaseOperate.java @@ -0,0 +1,33 @@ +package com.fr.design.designer.beans.adapters.layout; + +public interface DesignerBaseOperate { + + /** + * 是否支持复制 + * + * @return boolean + */ + boolean supportCopyAction(); + + /** + * 是否支持剪切 + * + * @return boolean + */ + boolean supportCutAction(); + + /** + * 是否支持粘贴 + * + * @return boolean + */ + boolean supportPasteAction(); + + /** + * 是否支持删除 + * + * @return boolean + */ + boolean supportDeleteAction(); + +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index c893268ba..3e255d2a4 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -7,7 +7,8 @@ import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.GroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.HoverPainter; -import com.fr.design.designer.beans.painters.FRFitLayoutPainter; +import com.fr.design.designer.beans.LayoutAdapter; +import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XLayoutContainer; @@ -19,6 +20,7 @@ import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.properties.FRFitLayoutConstraints; import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel; +import com.fr.design.designer.treeview.XCreatorTreeCellRender; import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.utils.ComponentUtils; import com.fr.form.ui.LayoutBorderStyle; @@ -43,8 +45,6 @@ import java.util.Set; * @date 2014-6-24 */ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { - - public static final String WIDGETPANEICONPATH = "/com/fr/web/images/form/resources/layout_absolute.png"; private static final int DEPENDING_SCOPE = 3; private HoverPainter painter; //区分拖拽和编辑宽高 @@ -58,6 +58,8 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { isEdit = edit; } + private LayoutAdapter frLayoutState; + /** * 构造函数 * @@ -65,10 +67,18 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { */ public FRFitLayoutAdapter(XLayoutContainer container) { super(container); - painter = new FRFitLayoutPainter(container); initMinSize(); + this.frLayoutState = new FRNoFixLayoutAdapter(this, container, minHeight); + painter = this.frLayoutState.getPainter(); } + + public void setFrLayoutState(LayoutAdapter frLayoutState){ + this.frLayoutState = frLayoutState; + painter = this.frLayoutState.getPainter(); + } + + private void initMinSize() { XWFitLayout layout = (XWFitLayout) container; minWidth = layout.getActualMinWidth(); @@ -100,16 +110,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { */ @Override public void addComp(XCreator child, int x, int y) { - fix(child, x, y); - if (child.shouldScaleCreator() || child.hasTitleStyle()) { - addParentCreator(child); - } else { - container.add(child, child.toData().getWidgetName()); - } - XWFitLayout layout = (XWFitLayout) container; - // 更新对应的BoundsWidget - layout.updateBoundsWidget(); - updateCreatorBackBound(); + frLayoutState.addBean(child, x, y); } public void updateCreatorBackBound() { @@ -130,11 +131,6 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { } - private void addParentCreator(XCreator child) { - XLayoutContainer parentPanel = child.initCreatorWrapper(minHeight); - container.add(parentPanel, child.toData().getWidgetName()); - } - /** * 能否对应位置放置当前组件 * @@ -206,7 +202,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { * @param y 纵坐标 * @return 是否在组件边缘 */ - public boolean matchEdge(int x, int y) { + private boolean matchEdge(int x, int y) { if (intersectsEdge(x, y, container)) { //寻找最近的fit, 在边缘地段添加的控件, 将其送给该fit XLayoutContainer parent = container.findNearestFit(); @@ -760,15 +756,9 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { super.fixTrisect(currentComp, child, x, y); } - /** - * 删除组件或者重新拖动时,其它组件重新计算位置大小 - */ - protected void delete(XCreator creator, int creatorWidth, int creatorHeight) { - int x = creator.getX(); - int y = creator.getY(); - recalculateChildrenSize(x, y, creatorWidth, creatorHeight, true); + public void removeBean(XCreator creator, int creatorWidth, int creatorHeight) { + frLayoutState.removeBean(creator, creatorWidth, creatorHeight); } - /** * 重新计算内部组件大小 * @@ -1216,11 +1206,11 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { /** * 删除或拉伸上边框 调整上方的组件位置大小 */ - protected boolean calculateUpRelatComponent(int objHeight) { + private boolean calculateUpRelatComponent(int objHeight) { return calculateUpRelatComponent(objHeight, false); } - protected boolean calculateUpRelatComponent(int objHeight, boolean isDel) { + private boolean calculateUpRelatComponent(int objHeight, boolean isDel) { if (!isDel && isBeyondAdjustHeightScope(objHeight)) { return false; } @@ -1248,4 +1238,25 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { public ConstraintsGroupModel getLayoutConstraints(XCreator creator) { return new FRFitLayoutConstraints((XWFitLayout) container, creator); } + + public XCreatorTreeCellRender getLayoutTreeCellRender(XCreator creator){ + return frLayoutState.getLayoutTreeCellRender(creator); + } + + @Override + public DesignerBaseOperate getDesignerBaseOperate() { + return frLayoutState.getDesignerBaseOperate(); + } + + public boolean supportModifyInsert() { + return frLayoutState.supportModifyInsert(); + } + + public void dragStart(XCreator xCreator, SelectionModel selectionModel){ + frLayoutState.dragStart(xCreator, selectionModel); + } + + public void dragOver(XCreator xCreator, SelectionModel selectionModel,int x, int y) { + frLayoutState.dragOver(xCreator, selectionModel,x,y); + }; } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFixLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFixLayoutAdapter.java new file mode 100644 index 000000000..798b277f6 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFixLayoutAdapter.java @@ -0,0 +1,134 @@ +package com.fr.design.designer.beans.adapters.layout; + +import com.fr.base.svg.IconUtils; +import com.fr.design.designer.beans.HoverPainter; +import com.fr.design.designer.beans.models.ModelUtil; +import com.fr.design.designer.beans.models.SelectionModel; +import com.fr.design.designer.beans.painters.FRFixLayoutPainter; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XOccupiedLayout; +import com.fr.design.designer.treeview.DefaultXCreatorTreeCellRender; +import com.fr.design.designer.treeview.XCreatorTreeCellRender; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.form.ui.container.OccupiedLayout; +import javax.swing.Icon; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; + +public class FRFixLayoutAdapter extends AbstractLayoutAdapter { + private static final Icon OCCUPIED_ICON = IconUtils.readIcon("/com/fr/design/form/images/occupied_layout.png"); + + public FRFixLayoutAdapter(XLayoutContainer container) { + super(container); + } + + public void addComp(XCreator child, int x, int y) { + Component component = container.getComponentAt(x, y); + if (component == container) { + return; + } + child.setLocation(component.getX(), component.getY()); + child.setSize(component.getWidth(), component.getHeight()); + container.remove(component); + if (child.shouldScaleCreator() || child.hasTitleStyle()) { + XLayoutContainer parentPanel = child.initCreatorWrapper(21); + container.add(parentPanel, child.toData().getWidgetName()); + } else { + container.add(child, child.toData().getWidgetName()); + } + if (child.getBackupRectangle() != null && child.getParent() == container) { + Component origin = container.getComponentAt(child.getBackupRectangle().x + 5, child.getBackupRectangle().y + 5); + if (origin == container) { + return; + } + if (origin instanceof XOccupiedLayout) { + ((XOccupiedLayout) origin).getLayoutAdapter().addBean((XCreator) component, child.getBackupRectangle().x + 5, child.getBackupRectangle().y + 5); + } + } + } + + @Override + public void delete(XCreator creator, int creatorWidth, int creatorHeight) { + OccupiedLayout occupiedLayout = new OccupiedLayout(); + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + XOccupiedLayout xoccupiedLayout = new XOccupiedLayout(occupiedLayout, new Dimension()); + ModelUtil.renameWidgetName(formDesigner.getTarget(), xoccupiedLayout); + xoccupiedLayout.setLocation(creator.getX(), creator.getY()); + xoccupiedLayout.setSize(creatorWidth, creatorHeight); + container.add(xoccupiedLayout); + } + + @Override + public XCreatorTreeCellRender getLayoutTreeCellRender(XCreator creator) { + return new DefaultXCreatorTreeCellRender(creator) { + @Override + public void paint(Graphics g, Component c) { + if (!getxCreator().acceptType(XOccupiedLayout.class)) { + OCCUPIED_ICON.paintIcon(c, g, 0, 0); + } + super.paint(g, c); + } + }; + } + + @Override + public boolean supportModifyInsert() { + return false; + } + + @Override + public DesignerBaseOperate getDesignerBaseOperate() { + return new DesignerBaseOperate() { + @Override + public boolean supportCopyAction() { + return false; + } + + @Override + public boolean supportCutAction() { + return false; + } + + @Override + public boolean supportPasteAction() { + return false; + } + + @Override + public boolean supportDeleteAction() { + return true; + } + }; + } + + @Override + public boolean accept(XCreator creator, int x, int y) { + return true; + } + + + @Override + public HoverPainter getPainter() { + return new FRFixLayoutPainter(container); + } + + @Override + public void dragStart(XCreator xCreator, SelectionModel selectionModel) { + //do nothing + } + + public void dragOver(XCreator xCreator, SelectionModel selectionModel, int x, int y) { + //当鼠标移出被拖拽的组件时,才将组件从selectionmodel 中移出 + if (xCreator.getBackupRectangle()!= null && !xCreator.getBackupRectangle().contains(x, y) + && selectionModel.getSelection().contains(xCreator.toData())) { + selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight()); + selectionModel.setSelectedCreator(container); + } + + } + + ; +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java new file mode 100644 index 000000000..bdf67e00e --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java @@ -0,0 +1,116 @@ +package com.fr.design.designer.beans.adapters.layout; + +import com.fr.design.designer.beans.models.SelectionModel; +import com.fr.design.designer.beans.painters.AbstractPainter; +import com.fr.design.designer.beans.painters.FRFitLayoutPainter; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; + +import java.awt.Component; +import java.util.ArrayList; + +public class FRNoFixLayoutAdapter extends AbstractLayoutAdapter { + private int minHeight; + private FRBodyLayoutAdapter parentLayoutAdapter; + + public FRNoFixLayoutAdapter(FRBodyLayoutAdapter parentLayoutAdapter, XLayoutContainer container, int minHeight) { + super(container); + this.parentLayoutAdapter = parentLayoutAdapter; + this.minHeight = minHeight; + } + + @Override + public void addComp(XCreator child, int x, int y) { + fix(child, x, y); + if (child.shouldScaleCreator() || child.hasTitleStyle()) { + addParentCreator(child); + } else { + container.add(child, child.toData().getWidgetName()); + } + XWFitLayout layout = (XWFitLayout) container; + // 更新对应的BoundsWidget + layout.updateBoundsWidget(); + updateCreatorBackBound(); + } + + private void updateCreatorBackBound() { + for (int i = 0, size = container.getComponentCount(); i < size; i++) { + XCreator creator = (XCreator) container.getComponent(i); + creator.updateChildBound(minHeight); + creator.setBackupBound(creator.getBounds()); + //tab布局用到 + ArrayList childrenList = creator.getTargetChildrenList(); + for (int j = 0; j < childrenList.size(); j++) { + XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList.get(j); + for (int m = 0; m < tabLayout.getComponentCount(); m++) { + XCreator childCreator = tabLayout.getXCreator(m); + childCreator.setBackupBound(childCreator.getBounds()); + } + } + } + } + + private void addParentCreator(XCreator child) { + XLayoutContainer parentPanel = child.initCreatorWrapper(minHeight); + container.add(parentPanel, child.toData().getWidgetName()); + } + + private void fix(XCreator child, int x, int y) { + Component parentComp = container.getComponentAt(x, y); + if (container.getComponentCount() == 0) { + child.setLocation(0, 0); + child.setSize(parentComp.getWidth(), parentComp.getHeight()); + } else if (parentLayoutAdapter.isCrossPointArea(parentComp, x, y)) { + //交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入 + parentLayoutAdapter.fixCrossPointArea(parentComp, child, x, y); + return; + } else if (parentLayoutAdapter.isTrisectionArea(parentComp, x, y)) { + // 在边界三等分区域,就不再和组件二等分了 + parentLayoutAdapter.fixTrisect(parentComp, child, x, y); + return; + } else { + parentLayoutAdapter.fixHalve(parentComp, child, x, y); + } + } + + @Override + public void delete(XCreator creator, int creatorWidth, int creatorHeight) { + int x = creator.getX(); + int y = creator.getY(); + ((FRFitLayoutAdapter)parentLayoutAdapter).recalculateChildrenSize(x, y, creatorWidth, creatorHeight, true); + } + + + @Override + public boolean supportModifyInsert() { + return true; + } + + @Override + public DesignerBaseOperate getDesignerBaseOperate() { + return new DefaultDesignerBaseOperate() { + @Override + public boolean supportCutAction() { + return container.getComponentCount() > 1; + } + }; + } + + @Override + public boolean accept(XCreator creator, int x, int y) { + return true; + } + + @Override + public AbstractPainter getPainter() { + return new FRFitLayoutPainter(container); + } + + @Override + public void dragStart(XCreator xCreator, SelectionModel selectionModel) { + selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight()); + selectionModel.setSelectedCreator(container); + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FROccupiedLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FROccupiedLayoutAdapter.java new file mode 100644 index 000000000..6c6aa2647 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FROccupiedLayoutAdapter.java @@ -0,0 +1,68 @@ +package com.fr.design.designer.beans.adapters.layout; + +import com.fr.design.designer.beans.HoverPainter; +import com.fr.design.designer.beans.painters.FROccupiedLayoutPainter; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.treeview.DefaultXCreatorTreeCellRender; +import com.fr.design.designer.treeview.XCreatorTreeCellRender; +import com.fr.design.utils.gui.LayoutUtils; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Graphics; + +public class FROccupiedLayoutAdapter extends AbstractLayoutAdapter { + + + public FROccupiedLayoutAdapter(XLayoutContainer container) { + super(container); + painter = new FROccupiedLayoutPainter(container); + } + + + private HoverPainter painter; + + + @Override + protected void addComp(XCreator creator, int x, int y) { + if (container.getComponentCount() == 0) { + creator.setLocation(container.getLocation().x, container.getLocation().y); + creator.setSize(container.getWidth(), container.getHeight()); + //将 xcreator 添加到其父容器中,并删除此 + XLayoutContainer parent = (XLayoutContainer) container.getParent(); + parent.getLayoutAdapter().removeBean(container, container.getWidth(), container.getHeight()); + if (creator.shouldScaleCreator() || creator.hasTitleStyle()) { + XLayoutContainer parentPanel = creator.initCreatorWrapper(21); + parent.add(parentPanel, creator.toData().getWidgetName()); + } else { + parent.add(creator, creator.toData().getWidgetName()); + } + LayoutUtils.layoutContainer(parent); + } + } + + @Override + public HoverPainter getPainter() { + return painter; + } + + @Override + public boolean accept(XCreator creator, int x, int y) { + return container.getComponentCount() == 0; + } + + public XCreatorTreeCellRender getLayoutTreeCellRender(XCreator creator) { + return new DefaultXCreatorTreeCellRender(creator) { + @Override + public void paint(Graphics g, Component c) { + super.paint(g, c); + Color oldColor = g.getColor(); + g.setColor(Color.RED); + g.drawRect(0, 0, 16, 16); + g.setColor(oldColor); + } + }; + } + +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java index c0b6cd400..e55aa86d3 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java @@ -51,9 +51,8 @@ public class AddingModel { this.creator = xCreator; this.creator.backupCurrentSize(); this.creator.backupParent(); - this.creator.setSize(xCreator.initEditorSize()); - currentX = x - (xCreator.getWidth() / 2); - currentY = y - (xCreator.getHeight() / 2); + currentX = x - (xCreator.initEditorSize().width / 2); + currentY = y - (xCreator.initEditorSize().height / 2); } /** @@ -93,8 +92,8 @@ public class AddingModel { * @param y 坐标 */ public void moveTo(int x, int y) { - currentX = x - (this.creator.getWidth() / 2); - currentY = y - (this.creator.getHeight() / 2); + currentX = x - (this.creator.initEditorSize().width / 2); + currentY = y - (this.creator.initEditorSize().height / 2); } public XCreator getXCreator() { diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java index 0f75896e1..dda70b96f 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java @@ -18,7 +18,7 @@ import java.util.Set; /** * created by Harrison on 2020/06/05 **/ -abstract class ModelUtil { +public abstract class ModelUtil { public static void renameWidgetName(Form form, XCreator xCreator) { diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/painters/FRFixLayoutPainter.java b/designer-form/src/main/java/com/fr/design/designer/beans/painters/FRFixLayoutPainter.java new file mode 100644 index 000000000..f450a437a --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/painters/FRFixLayoutPainter.java @@ -0,0 +1,130 @@ +package com.fr.design.designer.beans.painters; + +import com.fr.design.designer.beans.painters.AbstractPainter; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XOccupiedLayout; +import com.fr.design.form.util.XCreatorConstants; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Component; +import java.awt.Composite; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.Stroke; + +public class FRFixLayoutPainter extends AbstractPainter { + + /** + * 构造函数 + * + * @param container + */ + public FRFixLayoutPainter(XLayoutContainer container) { + super(container); + } + + /** + * 组件渲染 + * + * @param g 画图类 + * @param startX 开始位置x + * @param startY 开始位置y + */ + @Override + public void paint(Graphics g, int startX, int startY) { + super.paint(g, startX, startY); + int x = hotspot.x - hotspot_bounds.x; + int y = hotspot.y - hotspot_bounds.y; + Component currentComp = container.getComponentAt(x, y); + if (currentComp == null) { + return; + } + boolean accept = currentComp != container; + if (accept) { + OperateState state = OperateState.DEFAULT; + if (currentComp == creator) { + state = OperateState.COMPONENT_DRAG_OUT; + } else if (!((XCreator) currentComp).acceptType(XOccupiedLayout.class)) { + state = OperateState.COMPONENT_REPLACE; + } + state.paint(g, creator.getBackupRectangle(), currentComp.getBounds(), new Rectangle(x, y, creator.initEditorSize().width, ((XCreator) currentComp).initEditorSize().height)); + } else { + Color bColor = XCreatorConstants.LAYOUT_FORBIDDEN_COLOR; + int[] hot_rec = new int[]{x, y, 0, 0}; + drawHotspot(g, x, y, hot_rec[2], hot_rec[3], bColor, false, false); + } + + } + + + enum OperateState { + COMPONENT_REPLACE { + @Override + void paint(Graphics g, Rectangle oriRectangle, Rectangle currentRectangle, Rectangle hotspot_bounds) { + Graphics2D g2d = (Graphics2D) g; + Color color = g2d.getColor(); + Stroke backup = g2d.getStroke(); + Composite backupComp = g2d.getComposite(); + + g2d.setColor(XCreatorConstants.REPLACE_OCCUPIED_LAYOUT_COLOR); + g2d.setStroke(XCreatorConstants.DASH_STROKE); + //绘制当前组件的边框 + g2d.drawRect(currentRectangle.x, currentRectangle.y, currentRectangle.width, currentRectangle.height); + //底色透明度0.2 + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f)); + //绘制进行替换的时候,被替换的组件的底色 + g2d.fillRect(currentRectangle.x, currentRectangle.y, currentRectangle.width, currentRectangle.height); + + //绘制原组件位置处的占位块 + if (oriRectangle != null) { + g2d.setColor(XCreatorConstants.DRAG_OUT_OCCUPIED_LAYOUT_COLOR); + //如果是从其他占位块上拖过来的,绘制下其他占位块的状态 + g2d.drawRect(oriRectangle.x + 1, oriRectangle.y + 1, oriRectangle.width - 2, oriRectangle.height - 2); + //底色透明度0.2 + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f)); + //绘制进行替换的时候,被替换的组件的底色 + g2d.fillRect(oriRectangle.x, oriRectangle.y, oriRectangle.width, oriRectangle.height); + } + //还原 + g2d.setComposite(backupComp); + g2d.setStroke(backup); + g2d.setColor(color); + } + }, + COMPONENT_DRAG_OUT { + @Override + void paint(Graphics g, Rectangle oriRectangle, Rectangle currentRectangle, Rectangle hotspot_bounds) { + Graphics2D g2d = (Graphics2D) g; + Color color = g2d.getColor(); + Stroke backup = g2d.getStroke(); + Composite backupComp = g2d.getComposite(); + // 设置线条的样式 + g2d.setStroke(XCreatorConstants.DASH_STROKE); + g2d.setColor(XCreatorConstants.DRAG_OUT_OCCUPIED_LAYOUT_COLOR); + //如果是从其他占位块上拖过来的,绘制下其他占位块的状态 + g2d.drawRect(oriRectangle.x, oriRectangle.y, oriRectangle.width, oriRectangle.height); + //底色透明度0.2 + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f)); + //绘制进行替换的时候,被替换的组件的底色 + g2d.fillRect(oriRectangle.x, oriRectangle.y, oriRectangle.width, oriRectangle.height); + + g2d.setComposite(backupComp); + g2d.setStroke(backup); + g2d.setColor(color); + } + }, + DEFAULT { + @Override + void paint(Graphics g, Rectangle oriRectangle, Rectangle currentRectangle, Rectangle hotspot_bounds) { + + } + }; + + abstract void paint(Graphics g, Rectangle oriRectangle, Rectangle currentRectangle, Rectangle hotspot_bounds); + } + + +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/painters/FROccupiedLayoutPainter.java b/designer-form/src/main/java/com/fr/design/designer/beans/painters/FROccupiedLayoutPainter.java new file mode 100644 index 000000000..33a809a89 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/painters/FROccupiedLayoutPainter.java @@ -0,0 +1,56 @@ +package com.fr.design.designer.beans.painters; + +import com.fr.design.designer.beans.adapters.layout.FROccupiedLayoutAdapter; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.form.util.XCreatorConstants; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Component; +import java.awt.Composite; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Stroke; + +public class FROccupiedLayoutPainter extends AbstractPainter { + + /** + * 构造函数 + * + * @param container 容器 + */ + public FROccupiedLayoutPainter(XLayoutContainer container) { + super(container); + } + + @Override + public void paint(Graphics g, int startX, int startY) { + int x = hotspot.x - hotspot_bounds.x; + int y = hotspot.y - hotspot_bounds.y; + FROccupiedLayoutAdapter adapter = (FROccupiedLayoutAdapter) container.getLayoutAdapter(); + Component currentComp = container.getComponentAt(x, y); + if (currentComp == null) { + return; + } + boolean accept = adapter.accept(creator, x, y); + if (accept) { + Color backupColor = g.getColor(); + Graphics2D g2d = (Graphics2D) g; + Stroke backupStroke = g2d.getStroke(); + Composite backupComposite = g2d.getComposite(); + g2d.setColor(XCreatorConstants.DRAG_IN_OCCUPIED_LAYOUT_COLOR); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.05f)); + g2d.fillRect(container.getX(), container.getY(), container.getWidth(), container.getHeight()); + + g2d.setStroke(XCreatorConstants.DASH_STROKE); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f)); + g2d.drawRect(container.getX() + 1, container.getY() + 1, container.getWidth() - 2, container.getHeight() - 2); + g2d.setStroke(backupStroke); + g2d.setComposite(backupComposite); + g2d.setColor(backupColor); + } + + } + + +} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java index 395647db3..df8410946 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java @@ -21,6 +21,8 @@ import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.LineBorder; +import javax.swing.plaf.PanelUI; +import javax.swing.plaf.basic.BasicPanelUI; import java.awt.*; import java.awt.geom.Rectangle2D; import java.awt.geom.RoundRectangle2D; @@ -42,6 +44,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) { super(widget, initSize); + setUI(new NoBackgroundPaneUI()); setOpaque(false); setBackupBound(null); @@ -51,6 +54,13 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ } } + @Override + public void setUI(PanelUI ui) { + if (ui instanceof NoBackgroundPaneUI) { + super.setUI(ui); + } + } + public Background getBackground4Painting() { return this.background4Painting; } @@ -91,12 +101,12 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ super.addToWrapper(parentPanel, width, minHeight); // REPORT-53175: 新创建的图表组件默认显示标题 since 10.0.18 // 将当前对象添加到父容器后,初始化默认样式的效果 - initStyle(); + refreshStylePreviewEffect(); } - protected void initStyle() { + public void refreshStylePreviewEffect() { BorderPacker style = toData().getBorderStyle(); - initBorderAndBackgroundStyle(); + refreshBorderAndBackgroundStylePreviewEffect(); if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { initTitleStyle(style); } else { @@ -107,7 +117,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ reshuffleBorderAndBackgroundPaintingEffectIfTitleExists(); } - protected void initBorderAndBackgroundStyle() { + public void refreshBorderAndBackgroundStylePreviewEffect() { BorderPacker style = toData().getBorderStyle(); LineBorder DEFAULT_LINE_BORDER = (LineBorder) DEFALUTBORDER; @@ -288,6 +298,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ // 设计器预览界面中绘制组件背景效果 public void paintBackground(Graphics2D g2d) { + if (isOpaque()) { + g2d.setColor(getBackground()); + g2d.fillRect(0, 0, getWidth(), getHeight()); + } + Background background4Painting = getBackground4Painting(); if (background4Painting != null) { Composite oldComposite = g2d.getComposite(); @@ -311,12 +326,12 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ } public void paintForeground(Graphics2D g2d) { - super.paint(g2d); + super.paintComponent(g2d); super.paintBorder(g2d); } @Override - public void paint(Graphics g) { + public void paintComponent(Graphics g) { this.clipByRoundedBorder((Graphics2D) g); this.paintBackground((Graphics2D) g); this.paintBorderImage((Graphics2D) g); @@ -378,4 +393,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } } + + public static class NoBackgroundPaneUI extends BasicPanelUI { + @Override + public void update(Graphics g, JComponent c) { + paint(g, c); + } + } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java index 30fd6d2b9..020dac063 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java @@ -122,7 +122,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator { @Override public void propertyChange() { - initStyle(); + refreshStylePreviewEffect(); } }), }; @@ -165,7 +165,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator { @Override protected void initXCreatorProperties() { super.initXCreatorProperties(); - initBorderAndBackgroundStyle(); + refreshBorderAndBackgroundStylePreviewEffect(); BaseChartCollection collection = ((BaseChartEditor) data).getChartCollection(); isRefreshing = true; ((MiddleChartComponent) designerEditor.getEditorTarget()).populate(collection); @@ -232,7 +232,14 @@ public class XChartEditor extends XBorderStyleWidgetCreator { Dimension size = getSize(); PaddingMargin margin = toData().getMargin(); - designerEditor.paintEditor(g, size, margin); + if (!isEditing) { + // CHART-20568 & CHART-20627 + // EditingMouseListener#startEditing会将图表的ChartComponent放入FormDesigner, 作为编辑中的ChartComponent来显示, + // 同时这里又在下层绘制了一遍ChartComponent,导致图表进入编辑状态,会出现两个重叠的ChartComponent。 + // 考虑到编辑中,FormDesigner中的ChartComponent位于上层,下层的ChartComponent实际上没什么用,所以可以不用绘制 + // 下层的ChartComponent + designerEditor.paintEditor(g, size, margin); + } if (coverPanel != null) { int horizonMargin = margin != null ? margin.getLeft() + margin.getRight() : 0; @@ -338,7 +345,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator { * data属性改变触发其他操作 */ public void firePropertyChange() { - initStyle(); + refreshStylePreviewEffect(); } @Override 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 51b57cf0b..4601c268a 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 @@ -9,6 +9,10 @@ import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.designer.beans.events.DesignerEditor; import com.fr.design.designer.beans.models.SelectionModel; +import com.fr.design.designer.creator.operate.XCreatorBaseOperate; +import com.fr.design.designer.creator.operate.DefaultXCreatorBaseOperate; +import com.fr.design.designer.treeview.DefaultXCreatorTreeCellRender; +import com.fr.design.designer.treeview.XCreatorTreeCellRender; import com.fr.design.designer.ui.SelectedPopupDialog; import com.fr.design.fun.ShareWidgetUIProcessor; import com.fr.design.fun.WidgetPropertyUIProvider; @@ -62,7 +66,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo protected static final Dimension MIDDLE_PREFERRED_SIZE = new Dimension(80, 50); protected static final Dimension BIG_PREFERRED_SIZE = new Dimension(80, 80); // barry: 拖拽控件时,控件要恢复原始大小,就先把控件当前大小备份到这里。 - protected Dimension backupSize; + protected Rectangle backupRectangle; protected XLayoutContainer backupParent; protected Widget data; @@ -107,11 +111,15 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo * 应用备份的大小 */ public void useBackupSize() { - if (this.backupSize != null) { - setSize(this.backupSize); + if (this.backupRectangle != null) { + setSize(new Dimension(this.backupRectangle.width, this.backupRectangle.height)); } } + public Rectangle getBackupRectangle(){ + return this.backupRectangle; + } + /** * 初始化组件大小 */ @@ -128,7 +136,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo * 备份当前大小 */ public void backupCurrentSize() { - this.backupSize = getSize(); + this.backupRectangle = getBounds(); } public XLayoutContainer getBackupParent() { @@ -904,4 +912,24 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo } return ((XCreator) this.getParent()).getLevel() + 1; } + + /** + * 获取组件在组件树中的显示方式 + * @return + */ + public XCreatorTreeCellRender getComponentTreeCellRender(){ + if (this.getBackupParent()!= null){ + return this.getBackupParent().getLayoutAdapter().getLayoutTreeCellRender(this); + } + return new DefaultXCreatorTreeCellRender(this); + } + + /** + * 获取组件支持的基本操作 + * @return + */ + public XCreatorBaseOperate getXCreatorBaseOperate() { + return new DefaultXCreatorBaseOperate(); + } + } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java index 6e44ad196..38fb9d73e 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java @@ -3,6 +3,8 @@ */ package com.fr.design.designer.creator; +import com.fr.base.theme.FineColorFlushUtils; +import com.fr.base.theme.FineColorGather; import com.fr.base.theme.FineColorManager; import com.fr.base.theme.FormTheme; import com.fr.base.theme.TemplateTheme; @@ -26,6 +28,7 @@ import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.main.Form; import com.fr.form.main.WidgetGather; import com.fr.form.parameter.FormSubmitButton; +import com.fr.form.ui.AbstractBorderStyleWidget; import com.fr.form.ui.Button; import com.fr.form.ui.CardAddButton; import com.fr.form.ui.CardSwitchButton; @@ -52,6 +55,7 @@ import com.fr.form.ui.TreeComboBoxEditor; import com.fr.form.ui.TreeEditor; import com.fr.form.ui.Widget; import com.fr.form.ui.WidgetErrorMarker; +import com.fr.form.ui.container.OccupiedLayout; import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WBorderLayout; @@ -135,6 +139,7 @@ public class XCreatorUtils { xLayoutMap.put(WBorderLayout.class, XWBorderLayout.class); xLayoutMap.put(WCardLayout.class, XWCardLayout.class); xLayoutMap.put(WVerticalBoxLayout.class, XWVerticalBoxLayout.class); + xLayoutMap.put(OccupiedLayout.class, XOccupiedLayout.class); xLayoutMap.put(WFitLayout.class, XWFitLayout.class); xLayoutMap.put(WScaleLayout.class, XWScaleLayout.class); @@ -230,7 +235,7 @@ public class XCreatorUtils { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); TemplateTheme theme = template.getTemplateTheme(); if (theme instanceof FormTheme) { - setupTemplateTheme(creator, (FormTheme) theme, TemplateThemeCompatible.NONE); + setupTemplateTheme(creator, true, (FormTheme) theme, TemplateThemeCompatible.NONE); } return creator; } @@ -376,13 +381,16 @@ public class XCreatorUtils { return null; } - public static void setupTemplateTheme(XCreator container, final FormTheme currentTemplateUsingTheme, TemplateThemeCompatible compatible) { - FineColorManager.traverse(container.toData(), new FineColorManager.FineColorReplaceByTheme(currentTemplateUsingTheme, compatible)); + public static void setupTemplateTheme(XCreator container, final boolean forceFollowingTheme, final FormTheme currentTemplateUsingTheme, TemplateThemeCompatible compatible) { + FineColorGather colorGather = new FineColorManager.FineColorReplaceByTheme(currentTemplateUsingTheme, compatible); Form.traversalWidget(container.toData(), new WidgetGather() { @Override public void dealWith(Widget widget) { TemplateThemeAware themedWidget = (TemplateThemeAware) widget; + if (forceFollowingTheme && widget instanceof AbstractBorderStyleWidget) { + ((AbstractBorderStyleWidget) widget).setBorderStyleFollowingTheme(true); + } themedWidget.onTemplateUsingThemeChange(currentTemplateUsingTheme, compatible); } @@ -391,5 +399,7 @@ public class XCreatorUtils { return true; } }, TemplateThemeAware.class); + FineColorFlushUtils.replaceCacheObject(container.toData(), colorGather); + FineColorManager.traverse(container.toData(), colorGather); } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java index a41caf6fa..42a14aee3 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java @@ -33,7 +33,7 @@ import java.beans.IntrospectionException; import java.beans.PropertyDescriptor; import java.util.Set; -public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider , Releasable { +public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider, Releasable { private UILabel imageLable; private FormDesigner designer; private static BufferedImage DEFAULT_BACKGROUND; @@ -50,15 +50,14 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme public XElementCase(ElementCaseEditor widget, Dimension initSize) { super(widget, initSize); - - + widget.getElementCaseImage().adjustImageSize(initSize.width, initSize.height, false); } protected void initXCreatorProperties() { super.initXCreatorProperties(); // 报表块初始化时要加载对应的borderStyle - initBorderAndBackgroundStyle(); + refreshBorderAndBackgroundStylePreviewEffect(); } /** @@ -94,7 +93,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme @Override public void propertyChange() { - initStyle(); + refreshStylePreviewEffect(); } }), new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) @@ -269,6 +268,12 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme return toData().getElementCase(); } + @Override + public void doLayout() { + super.doLayout(); + this.updateECImage(); + } + public String getElementCaseContainerName() { return toData().getWidgetName(); } @@ -338,7 +343,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme * */ public void firePropertyChange() { - initStyle(); + refreshStylePreviewEffect(); } /** diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java b/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java index d4bd11bbb..12812880d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java @@ -52,6 +52,8 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme private volatile boolean dragInAble; + protected boolean isFixLayout = false; + public void setMouseEnter(boolean mouseEnter) { isMouseEnter = mouseEnter; } @@ -61,6 +63,10 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme this.addContainerListener(this); } + public void setFixLayout(boolean isFixLayout){ + this.isFixLayout = isFixLayout; + } + /** * 得到属性名 * @@ -77,7 +83,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme @Override public void propertyChange() { - initStyle(); + refreshStylePreviewEffect(); } }), new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) @@ -120,7 +126,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme @Override protected void initXCreatorProperties() { super.initXCreatorProperties(); - initBorderAndBackgroundStyle(); + refreshBorderAndBackgroundStylePreviewEffect(); this.initLayoutManager(); this.convert(); } @@ -549,7 +555,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme * */ public void firePropertyChange(){ - initStyle(); + refreshStylePreviewEffect(); } /** @@ -598,4 +604,8 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme editingMouseListener.refreshTopXCreator(editing); designer.repaint(); } + + public boolean supportFixLayout(){ + return false; + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XOccupiedLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XOccupiedLayout.java new file mode 100644 index 000000000..561a9437c --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XOccupiedLayout.java @@ -0,0 +1,81 @@ +package com.fr.design.designer.creator; + +import com.fr.design.designer.beans.LayoutAdapter; +import com.fr.design.designer.beans.adapters.layout.FROccupiedLayoutAdapter; +import com.fr.design.designer.creator.operate.DefaultXCreatorBaseOperate; +import com.fr.design.designer.creator.operate.XCreatorBaseOperate; +import com.fr.design.form.layout.FRFitLayout; +import com.fr.design.form.util.XCreatorConstants; +import com.fr.form.ui.container.OccupiedLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Stroke; + +public class XOccupiedLayout extends XLayoutContainer { + + public XOccupiedLayout() { + this(new OccupiedLayout(), new Dimension()); + } + + + public XOccupiedLayout(OccupiedLayout widget, Dimension initSize) { + super(widget, initSize); + initLayoutManager(); + } + + public String createDefaultName() { + return "box"; + } + + @Override + protected void initLayoutManager() { + this.setLayout(new FRFitLayout()); + } + + @Override + public LayoutAdapter getLayoutAdapter() { + return new FROccupiedLayoutAdapter(this); + } + + + public String getIconPath() { + return "/com/fr/design/form/images/occupied_layout.png"; + } + + + @Override + public boolean isComponentTreeLeaf() { + //在控件树上表现为叶子节点(组件放置到占位块中的时候,会删除占位块,只展示组件) + return true; + } + + public XCreatorBaseOperate getXCreatorBaseOperate() { + return new DefaultXCreatorBaseOperate() { + @Override + public boolean supportSelected() { + return false; + } + }; + } + + + @Override + public void paint(Graphics g) { + drawOccupiedComponentBounds(g); + } + + private void drawOccupiedComponentBounds(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + Color color = g2d.getColor(); + Stroke backup = g2d.getStroke(); + // 设置线条的样式 + g2d.setStroke(XCreatorConstants.DASH_STROKE); + g2d.setColor(XCreatorConstants.EMPTY_OCCUPIED_LAYOUT_COLOR); + g2d.drawRect(1, 1, this.getWidth() - 2, this.getHeight() - 2); + g2d.setStroke(backup); + g2d.setColor(color); + } + +} diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java index aa5612c09..b00f6710b 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java @@ -78,7 +78,7 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { @Override public void propertyChange() { - initStyle(); + XWAbsoluteBodyLayout.this.refreshStylePreviewEffect(); } }) }; @@ -105,8 +105,8 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { } @Override - protected void initStyle() { - initBorderAndBackgroundStyle(); + public void refreshStylePreviewEffect() { + refreshBorderAndBackgroundStylePreviewEffect(); } /** @@ -114,7 +114,7 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { * */ public void firePropertyChange(){ - initStyle(); + this.refreshStylePreviewEffect(); } @Override diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java index 74c18a910..f249a651e 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -305,7 +305,7 @@ public class XWAbsoluteLayout extends XLayoutContainer { } @Override - protected void initStyle() { + public void refreshStylePreviewEffect() { // do nothing } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java index 191add9b8..9aacc7c5d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java @@ -2,6 +2,7 @@ package com.fr.design.designer.creator; import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter; +import com.fr.design.designer.beans.adapters.layout.FRFixLayoutAdapter; import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; @@ -80,7 +81,11 @@ public class XWFitLayout extends XLayoutContainer { @Override public LayoutAdapter getLayoutAdapter() { - return new FRFitLayoutAdapter(this); + FRFitLayoutAdapter layoutAdapter = new FRFitLayoutAdapter(this); + if (isFixLayout) { + layoutAdapter.setFrLayoutState(new FRFixLayoutAdapter(this)); + } + return layoutAdapter; } @Override @@ -866,8 +871,10 @@ public class XWFitLayout extends XLayoutContainer { Widget wgt = xwc.toData(); BoundsWidget bw = (BoundsWidget) wlayout.getBoundsWidget(wgt); wlayout.removeWidget(bw); - updateBoundsWidget(); - ((FRFitLayoutAdapter)getLayoutAdapter()).updateCreatorBackBound(); + if(!isFixLayout){ + updateBoundsWidget(); + ((FRFitLayoutAdapter)getLayoutAdapter()).updateCreatorBackBound(); + } } /** @@ -1005,7 +1012,7 @@ public class XWFitLayout extends XLayoutContainer { * @return 默认返回true */ public boolean canAddInterval(int interval) { - int val = interval/2; + int val = (interval - this.toData().getCompInterval())/2; for (int i=0, len=this.getComponentCount(); i { - private final PaddingBoundPane paddingBoundPane; - private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor; - private PropertyGroupPane extraPropertyGroupPane; - private PcFitExpandablePane pcFitExpandablePane; - - private static final String FIT_STATE_PC = "fitStateInPC"; - - public ElementEditorExtendDefinePane(XCreator xCreator) { - super(xCreator); - paddingBoundPane = new PaddingBoundPane(); - themePane.addFollowThemePane(paddingBoundPane, new FollowingThemePane.FollowingThemeActionChangeListener() { - @Override - public void onFollowingTheme(boolean following) { - paddingBoundPane.setVisible(!following); - - if (following) { - TemplateTheme theme = themePane.getUsingTheme(); - if (theme instanceof FormTheme) { - ThemedComponentStyle style = ((FormTheme) theme).getComponentStyle(); - int top = style.getPaddingTop(); - int bottom = style.getPaddingBottom(); - int left = style.getPaddingLeft(); - int right = style.getPaddingRight(); - paddingBoundPane.populateBean(new PaddingMargin(top, left, bottom, right)); - } - } - } - }); - } - - protected JPanel createCenterPane() { - JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - elementCaseToolBarEditor = new AccessibleElementCaseToolBarEditor(); - Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_EC_Toolbar")), elementCaseToolBarEditor}, - }; - JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); - panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0)); - CRPropertyDescriptor[] extraTableEditor = removeOldFitEditor(((XElementCase) creator).getExtraTableEditor()); - extraPropertyGroupPane = new PropertyGroupPane(extraTableEditor, creator); - centerPane.add(panel, BorderLayout.NORTH); - if (extraTableEditor.length > 0) { - centerPane.add(extraPropertyGroupPane, BorderLayout.CENTER); - } - pcFitExpandablePane = new PcFitExpandablePane(this); - centerPane.add(pcFitExpandablePane, BorderLayout.SOUTH); - return centerPane; - } - - private CRPropertyDescriptor[] removeOldFitEditor(CRPropertyDescriptor[] extraTableEditor) { - List list = new ArrayList(); - for (CRPropertyDescriptor crPropertyDescriptor : extraTableEditor) { - if (!ComparatorUtils.equals(FIT_STATE_PC, crPropertyDescriptor.getName())) { - list.add(crPropertyDescriptor); - } - } - return list.toArray(new CRPropertyDescriptor[list.size()]); - } - - protected ElementCaseEditor updateSubBean() { - ElementCaseEditor elementCaseEditor = (ElementCaseEditor) creator.toData(); - if (themePane.isFollowingTheme() || ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) { - paddingBoundPane.update(elementCaseEditor); - } - elementCaseEditor.setToolBars((FormToolBarManager[]) elementCaseToolBarEditor.getValue()); - ReportFitAttr fitAttr = pcFitExpandablePane.update(); - elementCaseEditor.setReportFitAttr(fitAttr); - return elementCaseEditor; - } - - - protected void populateSubBean(ElementCaseEditor ob) { - paddingBoundPane.populate(ob); - elementCaseToolBarEditor.setValue(ob.getToolBars()); - extraPropertyGroupPane.populate(ob); - pcFitExpandablePane.populate(ob.getReportFitAttr()); - - } -} diff --git a/designer-form/src/main/java/com/fr/design/fit/attrpane/FRAbsoluteBodyLayoutExtendDefinePane.java b/designer-form/src/main/java/com/fr/design/fit/attrpane/FRAbsoluteBodyLayoutExtendDefinePane.java deleted file mode 100644 index 5fafb8df8..000000000 --- a/designer-form/src/main/java/com/fr/design/fit/attrpane/FRAbsoluteBodyLayoutExtendDefinePane.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.fr.design.fit.attrpane; - -import com.fr.base.io.IOFile; -import com.fr.base.iofile.attr.WatermarkAttr; -import com.fr.base.theme.FormTheme; -import com.fr.base.theme.TemplateTheme; -import com.fr.design.data.DataCreatorUI; -import com.fr.design.designer.IntervalConstants; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XWFitLayout; -import com.fr.design.designer.properties.items.FRLayoutTypeItems; -import com.fr.design.designer.properties.items.Item; -import com.fr.design.foldablepane.UIExpandablePane; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.style.FollowingThemePane; -import com.fr.design.gui.xpane.LayoutStylePane; -import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.WidgetPropertyPane; -import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor; -import com.fr.design.utils.gui.UIComponentUtils; -import com.fr.design.widget.FRWidgetFactory; -import com.fr.design.widget.ui.designer.component.WidgetBoundPane; -import com.fr.design.widget.ui.designer.layout.FRAbsoluteLayoutDefinePane; -import com.fr.form.ui.LayoutBorderStyle; -import com.fr.form.ui.container.WAbsoluteBodyLayout; -import com.fr.form.ui.container.WAbsoluteLayout; -import com.fr.form.ui.container.WBodyLayoutType; -import com.fr.general.act.BorderPacker; -import com.fr.report.core.ReportUtils; - -import javax.swing.BorderFactory; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.Component; - -/** - * Created by kerry on 2020-04-22 - */ -public class FRAbsoluteBodyLayoutExtendDefinePane extends FRAbsoluteLayoutDefinePane { - private static final int MAX_LABEL_WIDTH = 80; - - protected FollowingThemePane themePane; - private LayoutStylePane stylePane; - private AccessibleBodyWatermarkEditor watermarkEditor; - - private UIComboBox layoutCombox; - private WBodyLayoutType layoutType = WBodyLayoutType.ABSOLUTE; - - public FRAbsoluteBodyLayoutExtendDefinePane(XCreator xCreator) { - super(xCreator); - } - - - public void initComponent() { - initUIComboBox(); - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - - JPanel panel1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); - this.add(panel1, BorderLayout.CENTER); - - UIExpandablePane scalePane = new UIExpandablePane( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Area_Scaling"), - 280, 20, - createAreaScalePane() - ); - panel1.add(scalePane, BorderLayout.NORTH); - - UIExpandablePane advancedPane = new UIExpandablePane( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), - 280, 20, - this.createAdvancePane()); - panel1.add(advancedPane, BorderLayout.CENTER); - - } - - public JPanel createAdvancePane() { - JPanel advancedContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - - themePane = new FollowingThemePane(Toolkit.i18nText("Fine-Design_Form_Body_Style_Setting")); - stylePane = new LayoutStylePane(); - themePane.addFollowThemePane(stylePane, new FollowingThemePane.FollowingThemeActionChangeListener() { - @Override - public void onFollowingTheme(boolean following) { - stylePane.supportBodyStyle(!following); - - BorderPacker style = stylePane.updateBean(); - if (following) { - TemplateTheme theme = themePane.getUsingTheme(); - if (theme instanceof FormTheme) { - style = ((FormTheme) theme).getBodyStyle().merge(style); - } - } - stylePane.populateBean((LayoutBorderStyle) style); - } - }); - advancedContentPane.add(themePane, BorderLayout.NORTH); - - watermarkEditor = new AccessibleBodyWatermarkEditor(); - JPanel watermarkPane = TableLayoutHelper.createGapTableLayoutPane( - new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor} - }, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1); - watermarkPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); - advancedContentPane.add(watermarkPane, BorderLayout.CENTER); - - return advancedContentPane; - } - - public JPanel createAreaScalePane() { - initLayoutComboBox(); - - UILabel layoutTypeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")); - UILabel scaleModeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode")); - - JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane( - new Component[][]{ - {layoutTypeLabel, layoutCombox}, - {scaleModeLabel, comboBox} - }, - TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); - - contentPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); - - JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - containerPane.add(contentPane, BorderLayout.CENTER); - containerPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); - - return containerPane; - } - - public void initLayoutComboBox() { - Item[] items = FRLayoutTypeItems.ITEMS; - DefaultComboBoxModel model = new DefaultComboBoxModel(); - for (Item item : items) { - model.addElement(item); - } - layoutCombox = new UIComboBox(model); - layoutCombox.setSelectedIndex(1); - } - - @Override - public String title4PopupWindow() { - return "absoluteBodyLayout"; - } - - public void populateSubPane(WAbsoluteLayout ob) { - layoutCombox.setSelectedIndex(1); - themePane.supportFollowingTheme(ob.supportThemed()); - themePane.setFollowingTheme(ob.isBorderStyleFollowingTheme()); - stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle()); - watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile())); - } - - public WAbsoluteBodyLayout updateSubPane() { - WAbsoluteBodyLayout layout = (WAbsoluteBodyLayout) creator.toData(); - Item item = (Item) layoutCombox.getSelectedItem(); - Object value = item.getValue(); - int state = 0; - if (value instanceof Integer) { - state = (Integer) value; - } - - if (layoutType == WBodyLayoutType.ABSOLUTE) { - ((XWFitLayout) creator.getBackupParent()).toData().resetStyle(); - if (state == WBodyLayoutType.FIT.getTypeValue()) { - XWFitLayout xwFitLayout = ((XWFitLayout)creator.getBackupParent()); - xwFitLayout.switch2FitBodyLayout(creator); - copyLayoutAttr(layout, xwFitLayout.toData()); - } - } - layout.setBorderStyleFollowingTheme(themePane.isFollowingTheme()); - layout.setBorderStyle(stylePane.updateBean()); - updateWatermark(); - return layout; - } - - private void updateWatermark() { - WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue(); - if (watermark != null) { - IOFile ioFile = getCurrentIOFile(); - ioFile.addAttrMark(watermark); - } - } - - private IOFile getCurrentIOFile() { - return WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget(); - } - - @Override - public DataCreatorUI dataUI() { - return null; - } - - -} diff --git a/designer-form/src/main/java/com/fr/design/fit/attrpane/FRAbsoluteLayoutExtendDefinePane.java b/designer-form/src/main/java/com/fr/design/fit/attrpane/FRAbsoluteLayoutExtendDefinePane.java deleted file mode 100644 index 60ffae3eb..000000000 --- a/designer-form/src/main/java/com/fr/design/fit/attrpane/FRAbsoluteLayoutExtendDefinePane.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.fr.design.fit.attrpane; - -import com.fr.design.designer.creator.XCreator; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.widget.ui.designer.layout.AbstractFRLayoutDefinePane; -import com.fr.form.ui.container.WAbsoluteLayout; - -/** - * Created by kerry on 2020-04-22 - */ -public class FRAbsoluteLayoutExtendDefinePane extends AbstractFRLayoutDefinePane { - - public FRAbsoluteLayoutExtendDefinePane(XCreator xCreator) { - super(xCreator); - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - } - - @Override - public void populateBean(WAbsoluteLayout ob) { - } - - @Override - public WAbsoluteLayout updateBean() { - WAbsoluteLayout wAbsoluteLayout = (WAbsoluteLayout) creator.toData(); - return wAbsoluteLayout; - } -} diff --git a/designer-form/src/main/java/com/fr/design/fit/attrpane/FRFitLayoutExtendDefinePane.java b/designer-form/src/main/java/com/fr/design/fit/attrpane/FRFitLayoutExtendDefinePane.java deleted file mode 100644 index 78e2c5c3a..000000000 --- a/designer-form/src/main/java/com/fr/design/fit/attrpane/FRFitLayoutExtendDefinePane.java +++ /dev/null @@ -1,282 +0,0 @@ -package com.fr.design.fit.attrpane; - - -import com.fr.base.io.IOFile; -import com.fr.base.iofile.attr.WatermarkAttr; -import com.fr.base.theme.FormTheme; -import com.fr.base.theme.TemplateTheme; -import com.fr.design.data.DataCreatorUI; -import com.fr.design.designer.IntervalConstants; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWAbsoluteBodyLayout; -import com.fr.design.designer.creator.XWFitLayout; -import com.fr.design.designer.creator.XWScaleLayout; -import com.fr.design.designer.properties.items.FRLayoutTypeItems; -import com.fr.design.designer.properties.items.Item; -import com.fr.design.foldablepane.UIExpandablePane; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.ispinner.UISpinner; -import com.fr.design.gui.style.FollowingThemePane; -import com.fr.design.gui.xpane.LayoutStylePane; -import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.FormDesigner; -import com.fr.design.mainframe.FormSelectionUtils; -import com.fr.design.mainframe.WidgetPropertyPane; -import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor; -import com.fr.design.utils.gui.UIComponentUtils; -import com.fr.design.widget.FRWidgetFactory; -import com.fr.design.widget.ui.designer.component.PaddingBoundPane; -import com.fr.design.widget.ui.designer.layout.AbstractFRLayoutDefinePane; -import com.fr.form.ui.LayoutBorderStyle; -import com.fr.form.ui.Widget; -import com.fr.form.ui.container.WAbsoluteBodyLayout; -import com.fr.form.ui.container.WAbsoluteLayout; -import com.fr.form.ui.container.WBodyLayoutType; -import com.fr.form.ui.container.WFitLayout; -import com.fr.general.ComparatorUtils; -import com.fr.general.act.BorderPacker; -import com.fr.log.FineLoggerFactory; -import com.fr.report.core.ReportUtils; - -import javax.swing.BorderFactory; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; - -/** - * Created by kerry on 2020-04-22 - */ -public class FRFitLayoutExtendDefinePane extends AbstractFRLayoutDefinePane { - private static final int ADAPT_LABEL_MAX_WIDTH = 80; - private XWFitLayout xWFitLayout; - private WFitLayout wFitLayout; - private UIComboBox layoutComboBox; - private UISpinner componentIntervel; - private PaddingBoundPane paddingBound; - private FollowingThemePane themePane; - private LayoutStylePane stylePane; - private AccessibleBodyWatermarkEditor watermarkEditor; - - public FRFitLayoutExtendDefinePane(XCreator xCreator) { - super(xCreator); - this.xWFitLayout = (XWFitLayout) xCreator; - wFitLayout = xWFitLayout.toData(); - initComponent(); - } - - - public void initComponent() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - UIExpandablePane layoutExpandablePane = new UIExpandablePane( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout"), - 280, 20, - createLayoutPane() - ); - this.add(layoutExpandablePane, BorderLayout.NORTH); - - JPanel advancePane = createAdvancePane(); - UIExpandablePane advanceExpandablePane = new UIExpandablePane( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), - 280, 20, - advancePane - ); - this.add(advanceExpandablePane, BorderLayout.CENTER); - } - - public JPanel createAdvancePane() { - JPanel contentPane0 = FRGUIPaneFactory.createBorderLayout_S_Pane(); - - themePane = new FollowingThemePane(Toolkit.i18nText("Fine-Design_Form_Body_Style_Setting")); - stylePane = new LayoutStylePane(); - themePane.addFollowThemePane(stylePane, new FollowingThemePane.FollowingThemeActionChangeListener() { - @Override - public void onFollowingTheme(boolean following) { - stylePane.supportBodyStyle(!following); - - BorderPacker style = stylePane.updateBean(); - if (following) { - TemplateTheme theme = themePane.getUsingTheme(); - if (theme instanceof FormTheme) { - style = ((FormTheme) theme).getBodyStyle().merge(style); - } - } - stylePane.populateBean((LayoutBorderStyle) style); - } - }); - contentPane0.add(themePane, BorderLayout.NORTH); - - JPanel contentPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); - contentPane0.add(contentPane1, BorderLayout.CENTER); - - watermarkEditor = new AccessibleBodyWatermarkEditor(); - JPanel waterMarkPane = TableLayoutHelper.createGapTableLayoutPane( - new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor} - }, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1); - waterMarkPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); - contentPane1.add(waterMarkPane, BorderLayout.NORTH); - - paddingBound = new PaddingBoundPane(); - contentPane1.add(paddingBound, BorderLayout.CENTER); - - return contentPane0; - } - - public JPanel createLayoutPane() { - JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - - layoutComboBox = initUIComboBox(FRLayoutTypeItems.ITEMS); - componentIntervel = new UISpinner(0, Integer.MAX_VALUE, 1, 0); - JPanel componentIntervelPane = UIComponentUtils.wrapWithBorderLayoutPane(componentIntervel); - - UILabel intervalLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Interval")); - - JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane( - new Component[][]{ - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")), layoutComboBox}, - {intervalLabel, componentIntervelPane} - }, - TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); - contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); - containerPane.add(contentPane, BorderLayout.CENTER); - - return containerPane; - } - - - public UIComboBox initUIComboBox(Item[] items) { - DefaultComboBoxModel model = new DefaultComboBoxModel(); - for (Item item : items) { - model.addElement(item); - } - return new UIComboBox(model); - } - - - @Override - public String title4PopupWindow() { - return "fitLayout"; - } - - @Override - public void populateBean(WFitLayout ob) { - FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - XLayoutContainer rootLayout = selectedBodyLayout(formDesigner); - if (rootLayout != formDesigner.getRootComponent() - && formDesigner.getSelectionModel().getSelection().getSelectedCreator() == formDesigner.getRootComponent()) { - formDesigner.getSelectionModel().setSelectedCreators( - FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{selectedBodyLayout(formDesigner).toData()})); - - } - paddingBound.populate(ob); - layoutComboBox.setSelectedIndex(ob.getBodyLayoutType().getTypeValue()); - componentIntervel.setValue(ob.getCompInterval()); - themePane.supportFollowingTheme(ob.supportThemed()); - themePane.setFollowingTheme(ob.isBorderStyleFollowingTheme()); - stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle()); - watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile())); - } - - private XLayoutContainer selectedBodyLayout(FormDesigner formDesigner) { - XLayoutContainer rootLayout = formDesigner.getRootComponent(); - if (rootLayout.getComponentCount() == 1 && rootLayout.getXCreator(0).acceptType(XWAbsoluteBodyLayout.class)) { - rootLayout = (XWAbsoluteBodyLayout) rootLayout.getXCreator(0); - } - return rootLayout; - } - - - @Override - public WFitLayout updateBean() { - WFitLayout layout = (WFitLayout) creator.toData(); - if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) { - paddingBound.update(layout); - } - layout.setBorderStyleFollowingTheme(themePane.isFollowingTheme()); - LayoutBorderStyle borderStyle = stylePane.updateBean(); - if (borderStyle != null) { - layout.setBorderStyle(borderStyle); - } - updateWatermark(); - Item item = (Item) layoutComboBox.getSelectedItem(); - Object value = item.getValue(); - int state = 0; - if (value instanceof Integer) { - state = (Integer) value; - } - //todo 验证下 - layout.setLayoutType(WBodyLayoutType.parse(state)); - try { - if (state == WBodyLayoutType.ABSOLUTE.getTypeValue()) { - WAbsoluteBodyLayout wAbsoluteBodyLayout = new WAbsoluteBodyLayout("body"); - wAbsoluteBodyLayout.setCompState(WAbsoluteLayout.STATE_FIXED); - Component[] components = xWFitLayout.getComponents(); - xWFitLayout.removeAll(); - layout.resetStyle(); - XWAbsoluteBodyLayout xwAbsoluteBodyLayout = xWFitLayout.getBackupParent() == null ? new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0, 0)) : (XWAbsoluteBodyLayout) xWFitLayout.getBackupParent(); - xWFitLayout.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0); - for (Component component : components) { - XCreator xCreator = (XCreator) component; - //部分控件被ScaleLayout包裹着,绝对布局里面要放出来 - if (xCreator.acceptType(XWScaleLayout.class)) { - if (xCreator.getComponentCount() > 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator()) { - component = xCreator.getComponent(0); - component.setBounds(xCreator.getBounds()); - } - } - xwAbsoluteBodyLayout.add(component); - } - copyLayoutAttr(wFitLayout, wAbsoluteBodyLayout); - xWFitLayout.setBackupParent(xwAbsoluteBodyLayout); - FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - formDesigner.getSelectionModel().setSelectedCreators( - FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout})); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - - } - - int intervelValue = (int) componentIntervel.getValue(); - if (xWFitLayout.canAddInterval(intervelValue)) { -// 设置完间隔后,要同步处理界面组件,容器刷新后显示出对应效果 - setLayoutGap(intervelValue); - } - - return layout; - } - - private void updateWatermark() { - WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue(); - if (watermark != null) { - IOFile ioFile = getCurrentIOFile(); - ioFile.addAttrMark(watermark); - } - } - - private IOFile getCurrentIOFile() { - return WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget(); - } - - private void setLayoutGap(int value) { - int interval = wFitLayout.getCompInterval(); - if (value != interval) { - xWFitLayout.moveContainerMargin(); - xWFitLayout.moveCompInterval(xWFitLayout.getAcualInterval()); - wFitLayout.setCompInterval(value); - xWFitLayout.addCompInterval(xWFitLayout.getAcualInterval()); - } - } - - @Override - public DataCreatorUI dataUI() { - return null; - } - -} diff --git a/designer-form/src/main/java/com/fr/design/fit/attrpane/RootDesignExtendDefinePane.java b/designer-form/src/main/java/com/fr/design/fit/attrpane/RootDesignExtendDefinePane.java deleted file mode 100644 index 8a8aa404a..000000000 --- a/designer-form/src/main/java/com/fr/design/fit/attrpane/RootDesignExtendDefinePane.java +++ /dev/null @@ -1,303 +0,0 @@ -package com.fr.design.fit.attrpane; - -import com.fr.base.BaseUtils; -import com.fr.design.ExtraDesignClassManager; -import com.fr.design.data.DataCreatorUI; -import com.fr.design.designer.IntervalConstants; -import com.fr.design.designer.creator.CRPropertyDescriptor; -import com.fr.design.designer.creator.PropertyGroupPane; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XWParameterLayout; -import com.fr.design.designer.properties.PropertyTab; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.fit.DesignerUIModeConfig; -import com.fr.design.fit.common.TemplateTool; -import com.fr.design.foldablepane.UIExpandablePane; -import com.fr.design.fun.ParameterExpandablePaneUIProvider; -import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.ispinner.UISpinner; -import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.FormDesigner; -import com.fr.design.mainframe.FormSelection; -import com.fr.design.mainframe.JTemplate; -import com.fr.design.mainframe.widget.accessibles.AccessibleBackgroundEditor; -import com.fr.design.utils.gui.LayoutUtils; -import com.fr.design.utils.gui.UIComponentUtils; -import com.fr.design.widget.ui.designer.AbstractDataModify; -import com.fr.design.widget.ui.designer.component.UIBoundSpinner; -import com.fr.form.ui.container.WParameterLayout; -import com.fr.general.Background; -import com.fr.report.stable.FormConstants; - -import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Rectangle; -import java.util.Set; - -public class RootDesignExtendDefinePane extends AbstractDataModify { - private XWParameterLayout root; - private UISpinner designerWidth; - private UISpinner paraHeight; - private UICheckBox displayReport; - private UICheckBox useParamsTemplate; - private AccessibleBackgroundEditor background; - private UIButtonGroup hAlignmentPane; - private UITextField labelNameTextField; - //是否是新设计模式下决策报表 - private boolean newForm; - private PropertyGroupPane extraPropertyGroupPane; - - public RootDesignExtendDefinePane(XCreator xCreator) { - super(xCreator); - newForm = TemplateTool.getCurrentEditingNewJForm() != null && DesignerUIModeConfig.getInstance().newUIMode(); - this.root = (XWParameterLayout) xCreator; - initComponent(); - } - - - public void initComponent() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - if (newForm) { - paraHeight = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0); - } else { - designerWidth = new UIBoundSpinner(1, Integer.MAX_VALUE, 1); - } - JPanel advancePane = createAdvancePane(); - UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane); - this.add(advanceExpandablePane, BorderLayout.NORTH); - JPanel layoutPane = createBoundsPane(); - UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Size"), 280, 20, layoutPane); - this.add(layoutExpandablePane, BorderLayout.CENTER); - this.addExtraUIExpandablePaneFromPlugin(); - } - - private void addExtraUIExpandablePaneFromPlugin() { - Set pluginCreators = ExtraDesignClassManager.getInstance().getArray(ParameterExpandablePaneUIProvider.XML_TAG); - JPanel panel = FRGUIPaneFactory.createYBoxEmptyBorderPane(); - for (ParameterExpandablePaneUIProvider provider : pluginCreators) { - UIExpandablePane uiExpandablePane = provider.createUIExpandablePane(); - PropertyTab propertyTab = provider.addToWhichPropertyTab(); - if (uiExpandablePane != null && propertyTab == PropertyTab.ATTR) { - panel.add(uiExpandablePane); - } - } - this.add(panel, BorderLayout.SOUTH); - } - - public JPanel createBoundsPane() { - double f = TableLayout.FILL; - double p = TableLayout.PREFERRED; - double[] rowSize = {p}; - double[] columnSize = {p, f}; - int[][] rowCount = {{1, 1}}; - Component[] component = newForm ? new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Design_Height")), paraHeight} : - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Desin_Width")), designerWidth}; - Component[][] components = new Component[][]{component}; - JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); - JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); - jPanel.add(panel); - return jPanel; - } - - public JPanel createAdvancePane() { - if (newForm) { - return getNewFormAdvancePane(); - } else { - return getTemplateAdvancePane(); - } - } - - /** - * @Description: 获取的非新决策报表AdvancePane - * @param - * @return: - * @Author: Henry.Wang - * @date: 2020/11/05 15:36 - */ - private JPanel getTemplateAdvancePane() { - JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - labelNameTextField = new UITextField(); - displayReport = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Display_Nothing_Before_Query")); - UIComponentUtils.setLineWrap(displayReport); - useParamsTemplate = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Use_Params_Template")); - background = new AccessibleBackgroundEditor(); - Icon[] hAlignmentIconArray = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), - BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), - BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"),}; - Integer[] hAlignment = new Integer[]{FormConstants.LEFTPOSITION, FormConstants.CENTERPOSITION, FormConstants.RIGHTPOSITION}; - hAlignmentPane = new UIButtonGroup(hAlignmentIconArray, hAlignment); - hAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Left") - , com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right")}); - double f = TableLayout.FILL; - double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p, p, p}; - double[] columnSize = {p, f}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; - Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), background}, - new Component[]{displayReport, null}, - new Component[]{useParamsTemplate, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Display_Position")), hAlignmentPane} - }; - JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); - panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); - CRPropertyDescriptor[] extraTableEditor = new CRPropertyDescriptor[0]; - extraTableEditor = root.getExtraTableEditor(); - extraPropertyGroupPane = new PropertyGroupPane(extraTableEditor, root); - - jPanel.add(panel, BorderLayout.NORTH); - jPanel.add(extraPropertyGroupPane, BorderLayout.CENTER); - return jPanel; - } - - /** - * @Description: 获取新决策报表的AdvancePane - * @param - * @return: - * @Author: Henry.Wang - * @date: 2020/11/05 15:36 - */ - private JPanel getNewFormAdvancePane() { - JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - labelNameTextField = new UITextField(); - displayReport = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Display_Nothing_Before_Query")); - UIComponentUtils.setLineWrap(displayReport); - useParamsTemplate = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Use_Params_Template")); - background = new AccessibleBackgroundEditor(); - - double f = TableLayout.FILL; - double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p, p}; - double[] columnSize = {p, f}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}}; - Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), background}, - new Component[]{displayReport, null}, - new Component[]{useParamsTemplate, null} - }; - JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); - panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); - - jPanel.add(panel, BorderLayout.NORTH); - - return jPanel; - } - - @Override - public String title4PopupWindow() { - return "parameter"; - } - - @Override - public void populateBean(WParameterLayout ob) { - labelNameTextField.setText(ob.getLabelName()); - background.setValue(ob.getBackground()); - displayReport.setSelected(ob.isDelayDisplayContent()); - useParamsTemplate.setSelected(ob.isUseParamsTemplate()); - if (newForm) { - FormDesigner designer = TemplateTool.getCurrentEditingNewJForm().getFormDesign(); - paraHeight.setValue(designer.getParaHeight()); - } else { - designerWidth.setValue(ob.getDesignWidth()); - hAlignmentPane.setSelectedItem(ob.getPosition()); - - if (extraPropertyGroupPane != null) { - extraPropertyGroupPane.populate(ob); - } - } - } - - - @Override - public WParameterLayout updateBean() { - if (newForm) { - return updateNewFormBean(); - } else { - return updateTemplateBean(); - } - } - - /** - * @Description: 更新非新决策报表的bean - * @param - * @return: - * @Author: Henry.Wang - * @date: 2020/11/05 15:36 - */ - private WParameterLayout updateTemplateBean() { - WParameterLayout wParameterLayout = (WParameterLayout) creator.toData(); - wParameterLayout.setLabelName(labelNameTextField.getText()); - if (isCompsOutOfDesignerWidth((int) designerWidth.getValue())) { - designerWidth.setValue(wParameterLayout.getDesignWidth()); - } else { - wParameterLayout.setDesignWidth((int) designerWidth.getValue()); - } - wParameterLayout.setDelayDisplayContent(displayReport.isSelected()); - wParameterLayout.setUseParamsTemplate(useParamsTemplate.isSelected()); - JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - jTemplate.needAddTemplateIdAttr(useParamsTemplate.isSelected()); - wParameterLayout.setBackground((Background) background.getValue()); - wParameterLayout.setPosition((Integer) hAlignmentPane.getSelectedItem()); - return wParameterLayout; - } - - /** - * @Description: 更新新决策报表的bean - * @param - * @return: - * @Author: Henry.Wang - * @date: 2020/11/05 15:36 - */ - private WParameterLayout updateNewFormBean() { - WParameterLayout wParameterLayout = (WParameterLayout) creator.toData(); - wParameterLayout.setLabelName(labelNameTextField.getText()); - - wParameterLayout.setDelayDisplayContent(displayReport.isSelected()); - wParameterLayout.setUseParamsTemplate(useParamsTemplate.isSelected()); - JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - jTemplate.needAddTemplateIdAttr(useParamsTemplate.isSelected()); - wParameterLayout.setBackground((Background) background.getValue()); - //设置参数模板面板的高度 - int height = (int) paraHeight.getTextField().getValue(); - FormDesigner designer = TemplateTool.getCurrentEditingNewJForm().getFormDesign(); - FormSelection selection = designer.getSelectionModel().getSelection(); - XCreator creator = designer.getParaComponent(); - Rectangle rectangle = creator.getBounds(); - Rectangle newRectangle = new Rectangle(rectangle.x, rectangle.y, rectangle.width, height); - creator.setBounds(newRectangle); - if (paraHeight.getValue() != newRectangle.height) - paraHeight.setValue(newRectangle.height); - designer.setParaHeight(newRectangle.height); - designer.getArea().doLayout(); - LayoutUtils.layoutContainer(creator); - selection.fixCreator(designer); - designer.repaint(); - return wParameterLayout; - } - - private boolean isCompsOutOfDesignerWidth(int designerWidth) { - for (int i = 0; i < root.getComponentCount(); i++) { - Component comp = root.getComponent(i); - if (comp.getX() + comp.getWidth() > designerWidth) { - return true; - } - } - return false; - } - - @Override - public DataCreatorUI dataUI() { - return null; - } -} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java b/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java index 8c55e8ab0..a5df5fabd 100644 --- a/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java +++ b/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java @@ -3,39 +3,24 @@ package com.fr.design.fit.common; import com.fr.design.data.DesignTableDataManager; import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.fit.NewJForm; -import com.fr.design.fit.attrpane.ElementEditorExtendDefinePane; -import com.fr.design.fit.attrpane.FRAbsoluteBodyLayoutExtendDefinePane; -import com.fr.design.fit.attrpane.FRAbsoluteLayoutExtendDefinePane; -import com.fr.design.fit.attrpane.FRFitLayoutExtendDefinePane; -import com.fr.design.fit.attrpane.RootDesignExtendDefinePane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JTemplate; -import com.fr.design.parameter.RootDesignDefinePane; import com.fr.design.preview.FormAdaptivePreview; import com.fr.design.preview.FormPreview; -import com.fr.design.widget.Appearance; -import com.fr.design.widget.FormWidgetDefinePaneFactoryBase; -import com.fr.design.widget.ui.designer.layout.ElementEditorDefinePane; -import com.fr.design.widget.ui.designer.layout.FRAbsoluteBodyLayoutDefinePane; -import com.fr.design.widget.ui.designer.layout.FRAbsoluteLayoutDefinePane; -import com.fr.design.widget.ui.designer.layout.FRFitLayoutDefinePane; import com.fr.file.FILE; import com.fr.file.MemFILE; import com.fr.form.main.Form; import com.fr.form.main.WidgetGather; -import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WFitLayout; -import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.log.FineLoggerFactory; import com.fr.report.fit.ReportFitAttr; import javax.swing.SwingUtilities; -import java.util.Set; /** * Created by kerry on 2020-06-02 @@ -55,16 +40,6 @@ public class AdaptiveSwitchUtil { public static void switch2NewUIMode() { DesignerUIModeConfig.getInstance().setNewUIMode(); - FormWidgetDefinePaneFactoryBase.registerDefinePane(ElementCaseEditor.class, - new Appearance(ElementEditorExtendDefinePane.class, "elementCaseEditor")); - FormWidgetDefinePaneFactoryBase.registerDefinePane(WFitLayout.class, - new Appearance(FRFitLayoutExtendDefinePane.class, "wFitLayout")); - FormWidgetDefinePaneFactoryBase.registerDefinePane(WAbsoluteBodyLayout.class, - new Appearance(FRAbsoluteBodyLayoutExtendDefinePane.class, "wAbsoluteBodyLayout")); - FormWidgetDefinePaneFactoryBase.registerDefinePane(WAbsoluteLayout.class, - new Appearance(FRAbsoluteLayoutExtendDefinePane.class, "wAbsoluteLayout")); - FormWidgetDefinePaneFactoryBase.registerDefinePane(WParameterLayout.class, - new Appearance(RootDesignExtendDefinePane.class, "wParameterLayout")); } public static void switch2OldUI() { @@ -74,16 +49,6 @@ public class AdaptiveSwitchUtil { public static void switch2OldUIMode() { DesignerUIModeConfig.getInstance().setOldUIMode(); - FormWidgetDefinePaneFactoryBase.registerDefinePane(WAbsoluteLayout.class, - new Appearance(FRAbsoluteLayoutDefinePane.class, "wAbsoluteLayout")); - FormWidgetDefinePaneFactoryBase.registerDefinePane(ElementCaseEditor.class, - new Appearance(ElementEditorDefinePane.class, "elementCaseEditor")); - FormWidgetDefinePaneFactoryBase.registerDefinePane(WAbsoluteBodyLayout.class, - new Appearance(FRAbsoluteBodyLayoutDefinePane.class, "wAbsoluteBodyLayout")); - FormWidgetDefinePaneFactoryBase.registerDefinePane(WFitLayout.class, - new Appearance(FRFitLayoutDefinePane.class, "wFitLayout")); - FormWidgetDefinePaneFactoryBase.registerDefinePane(WParameterLayout.class, - new Appearance(RootDesignDefinePane.class, "wParameterLayout")); } public static void reload() { diff --git a/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java b/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java index 323a28ad0..cb415df59 100644 --- a/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java +++ b/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java @@ -45,15 +45,8 @@ public class TemplateTool { JFormType currentType = JFormType.OLD_TYPE; if (AdaptiveSwitchUtil.isSwitchJFromIng()) { currentType = DesignerUIModeConfig.getInstance().newUIMode() ? JFormType.NEW_TYPE : JFormType.OLD_TYPE; - } else { - if (jTemplate instanceof NewJForm) { - NewJForm newJForm = (NewJForm) jTemplate; - if (newJForm.mobileForm()) { - currentType = JFormType.OLD_TYPE; - } else if (LightTool.containNewFormFlag(newJForm.getTarget()) || newJForm.getTarget().getTemplateID() == null) { - currentType = JFormType.NEW_TYPE; - } - } + } else if (isNewJForm(jTemplate)) { + currentType = JFormType.NEW_TYPE; } //UI转换 currentType.switchUIMode(); @@ -64,6 +57,16 @@ public class TemplateTool { } }; + private static boolean isNewJForm(JTemplate jTemplate) { + if (jTemplate instanceof NewJForm) { + NewJForm newJForm = (NewJForm) jTemplate; + if (LightTool.containNewFormFlag(newJForm.getTarget()) || newJForm.getTarget().getTemplateID() == null) { + return true; + } + } + return false; + } + public static Listener getSwitchListener() { return switchListener; } diff --git a/designer-form/src/main/java/com/fr/design/form/util/XCreatorConstants.java b/designer-form/src/main/java/com/fr/design/form/util/XCreatorConstants.java index 71ab3c002..c8513ea13 100644 --- a/designer-form/src/main/java/com/fr/design/form/util/XCreatorConstants.java +++ b/designer-form/src/main/java/com/fr/design/form/util/XCreatorConstants.java @@ -3,10 +3,14 @@ */ package com.fr.design.form.util; +import com.fr.base.GraphHelper; +import com.fr.stable.Constants; + import javax.swing.BorderFactory; import javax.swing.border.Border; import java.awt.BasicStroke; import java.awt.Color; +import java.awt.Stroke; /** * @author richer @@ -52,4 +56,19 @@ public class XCreatorConstants { // 不同粗细的线 public static final BasicStroke STROKE = new BasicStroke(2); + + public static final Stroke DASH_STROKE = GraphHelper.getStroke(Constants.LINE_MEDIUM_DASH); + + //空占位块 + public static final Color EMPTY_OCCUPIED_LAYOUT_COLOR = new Color(217, 218, 221); + + //添加组件/未释放 + public static final Color DRAG_IN_OCCUPIED_LAYOUT_COLOR = new Color(65, 155, 249); + + //固定布局中从占位块中拖出 + public static final Color DRAG_OUT_OCCUPIED_LAYOUT_COLOR = new Color(155, 172, 245); + + //从占位块中替换 + public static final Color REPLACE_OCCUPIED_LAYOUT_COLOR = new Color(247, 181, 0); + } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java index 826e2d5b7..684037d8b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java @@ -14,7 +14,6 @@ import com.fr.design.gui.itree.UITreeUI; import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.StringUtils; - import java.awt.Rectangle; import java.util.Stack; import java.util.function.Consumer; @@ -96,6 +95,10 @@ public class ComponentTree extends JTree { public void setSelectionPath(TreePath path) { // 不管点击哪一项,都要先退出编辑状态(图表、报表块、绝对布局、tab块) + Object widget = path.getLastPathComponent(); + if(widget == null ||!((XCreator)widget).getXCreatorBaseOperate().supportSelected()){ + return; + } designer.stopEditing(path); super.setSelectionPath(path); } @@ -368,7 +371,9 @@ public class ComponentTree extends JTree { Point point = tree.getPathBounds(path).getLocation(); SwingUtilities.convertPointToScreen(point, tree); XCreator comp = (XCreator) path.getLastPathComponent(); - popupPreviewPane(point.y, comp); + if (comp.getXCreatorBaseOperate().supportSelected()){ + popupPreviewPane(point.y, comp); + } } else { hidePreviewPane(); } @@ -384,7 +389,8 @@ public class ComponentTree extends JTree { onMouseEvent(e, new Consumer() { @Override public void accept(XCreator creator) { - if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner()) { + if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner() + &&creator.getXCreatorBaseOperate().supportSelected()) { startEditing(creator); } } @@ -397,7 +403,7 @@ public class ComponentTree extends JTree { onMouseEvent(e, new Consumer() { @Override public void accept(XCreator creator) { - if (e.getButton() == MouseEvent.BUTTON1) { + if (e.getButton() == MouseEvent.BUTTON1 && creator.getXCreatorBaseOperate().supportSelected()) { selectedCreator = creator; } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index a7244c0f2..b0463a685 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -636,7 +636,7 @@ public class EditingMouseListener extends MouseInputAdapter { XCreator oldCreator = creator; creator = processTopLayoutMouseClick(creator); - if (creator != null) { + if (creator != null && creator.getXCreatorBaseOperate().supportSelected()) { // tab块处于未编辑状态 boolean uneditedTab = designer.getCursor().getType() != Cursor.HAND_CURSOR && creator.acceptType(XWCardMainBorderLayout.class) && !((XWCardMainBorderLayout) creator).isEditable(); // 点击不在tab块的button中 diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java index 16dc8593e..648a2845d 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java @@ -1,12 +1,21 @@ package com.fr.design.mainframe; import com.fr.common.inputevent.InputEventBaseOnOS; +import com.fr.design.actions.UpdateAction; +import com.fr.design.constants.UIConstants; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.fit.DesignerUIModeConfig; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonUI; +import com.fr.design.gui.imenu.UIPopupMenu; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.share.ui.base.PopupMenuItem; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.form.fit.NewFormMarkAttr; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UINumberField; @@ -21,14 +30,17 @@ import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.main.mobile.FormMobileAttr; import com.fr.form.ui.container.WBorderLayout; -import com.fr.general.FRScreen; +import com.fr.general.IOUtils; import com.fr.stable.AssistUtils; import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.KeyStroke; +import javax.swing.SwingConstants; import javax.swing.border.LineBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -38,6 +50,8 @@ import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; @@ -80,6 +94,8 @@ public class FormArea extends JComponent implements ScrollRulerComponent { // 初始时滑块值为100,托动后的值设为START_VALUE; private double START_VALUE = DEFAULT_SLIDER; private double screenValue; + private UIButton fixLayoutSwitchButton; + private boolean isFixLayoutEditState; public FormScrollBar getHorScrollBar() { @@ -164,6 +180,38 @@ public class FormArea extends JComponent implements ScrollRulerComponent { } }; + private UIButton createFixLayoutSwitchButton(){ + UIButton button = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_No_Fix_Layout")); + button.setIcon(IOUtils.readIcon("/com/fr/base/images/share/filter_combo.png")); + button.setUI(new UIButtonUI(){ + @Override + protected void paintBorder(Graphics g, UIButton b) { + + } + protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) { + if (isPressed(b) && b.isPressedPainted()) { + GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles)); + } else if (isRollOver(b)) { + GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted()); + } + } + }); + button.setHorizontalTextPosition(SwingConstants.LEFT); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + UIPopupMenu popupMenu = new UIPopupMenu(); + popupMenu.setPreferredSize(new Dimension(180, 59)); + popupMenu.setOnlyText(true); + popupMenu.setBackground(UIConstants.DEFAULT_BG_RULER); + popupMenu.add(new PopupMenuItem(new Switch2NoFixLayoutAction())); + popupMenu.add(new PopupMenuItem(new Switch2FixLayoutAction())); + GUICoreUtils.showPopupMenu(popupMenu, fixLayoutSwitchButton, 0, -59); + } + }); + + return button; + } /** @@ -175,6 +223,11 @@ public class FormArea extends JComponent implements ScrollRulerComponent { double[] rowSize = {f}; double[] columnSize = {p, f, p, p, p, p, p, f, p}; UILabel tipsPane = new UILabel("form"); + fixLayoutSwitchButton = createFixLayoutSwitchButton(); + JPanel layoutSwitchPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + layoutSwitchPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); + layoutSwitchPane.add(fixLayoutSwitchButton); + widthPane = new UINumberField(); widthPane.setPreferredSize(new Dimension(60, 0)); heightPane = new UINumberField(); @@ -183,7 +236,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { slidePane = JFormSliderPane.getInstance(); JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane( - new JComponent[][]{{tipsPane, new UILabel(), widthPane, + new JComponent[][]{{tipsPane, layoutSwitchPane, widthPane, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")), new UILabel("x"), heightPane, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")), @@ -198,6 +251,25 @@ public class FormArea extends JComponent implements ScrollRulerComponent { slidePane.addValueChangeListener(showValSpinnerChangeListener); } + public void undoFixLayoutState(boolean isFixLayout) { + getFormEditor().getRootComponent().setFixLayout(isFixLayout); + this.switchLayout(isFixLayout); + } + + public void switchBodyLayout(XLayoutContainer xLayoutContainer) { + this.fixLayoutSwitchButton.setVisible(xLayoutContainer.supportFixLayout()); + this.switchLayout(true); + } + + private void switchLayout(boolean isFixLayout) { + this.isFixLayoutEditState = isFixLayout; + this.fixLayoutSwitchButton.setText(isFixLayout ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Fix_Layout") : + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_No_Fix_Layout")); + FormMobileAttr formMobileAttr = designer.getTarget().getFormMobileAttr(); + widthPane.setEnabled(!isFixLayout && !formMobileAttr.isMobileOnly()); + heightPane.setEnabled(!isFixLayout); + } + private void setWidgetsConfig() { widthPane.setHorizontalAlignment(widthPane.CENTER); @@ -281,8 +353,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { if(object instanceof XCreator){ updateCreatorsBackupBound((XCreator) object); } - } - } + } } //设置宽度的控件及响应事件 @@ -817,7 +888,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { } this.slidePane.setShowValue((int) slide); - } + } /** @@ -899,4 +970,43 @@ public class FormArea extends JComponent implements ScrollRulerComponent { } + public boolean isFixLayout(){ + return this.isFixLayoutEditState; + } + + class Switch2NoFixLayoutAction extends UpdateAction{ + public Switch2NoFixLayoutAction(){ + this.putValue(Action.SMALL_ICON, null); + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_No_Fix_Layout")); + this.setSmallIcon("/com/fr/design/form/images/no_fix_layout_icon.png"); + } + + @Override + public void actionPerformed(ActionEvent e) { + getFormEditor().getRootComponent().setFixLayout(false); + switchLayout(false); + designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); + DesignerContext.getDesignerFrame().refresh(); + } + } + + class Switch2FixLayoutAction extends UpdateAction{ + + public Switch2FixLayoutAction(){ + this.putValue(Action.SMALL_ICON, null); + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Fix_Layout")); + this.setSmallIcon("/com/fr/design/form/images/fix_layout_icon.png"); + } + + @Override + public void actionPerformed(ActionEvent e) { + getFormEditor().getRootComponent().setFixLayout(true); + switchLayout(true); + designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); + DesignerContext.getDesignerFrame().refresh(); + } + } + + + } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index 7db972e9b..926b6be5e 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -288,6 +288,7 @@ public class FormCreatorDropTarget extends DropTarget { int y = designer.getRelativeY(loc.y); hovering(x, y); tabDragInner.canDragIn(designer.getComponentAt(x, y), x, y); + designer.draggingComponent(x, y); } /** diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index cbe9e87e6..581255896 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -1,10 +1,6 @@ package com.fr.design.mainframe; import com.fr.base.Parameter; -import com.fr.base.ScreenResolution; -import com.fr.base.theme.FormTheme; -import com.fr.base.theme.TemplateTheme; -import com.fr.base.theme.TemplateThemeCompatible; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; @@ -22,7 +18,9 @@ import com.fr.design.designer.beans.actions.MoveToBottomAction; import com.fr.design.designer.beans.actions.MoveToTopAction; import com.fr.design.designer.beans.actions.MoveUpAction; import com.fr.design.designer.beans.actions.PasteAction; +import com.fr.design.designer.beans.adapters.layout.DefaultDesignerBaseOperate; import com.fr.design.designer.beans.adapters.layout.FRParameterLayoutAdapter; +import com.fr.design.designer.beans.adapters.layout.DesignerBaseOperate; import com.fr.design.designer.beans.events.CreatorEventListenerTable; import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; @@ -44,7 +42,6 @@ import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.DesignerOpenedListener; -import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.form.util.XCreatorConstants; @@ -61,9 +58,7 @@ import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseProvider; import com.fr.form.main.Form; -import com.fr.form.main.WidgetGather; import com.fr.form.parameter.FormSubmitButton; -import com.fr.form.ui.AbstractBorderStyleWidget; import com.fr.form.ui.EditorHolder; import com.fr.form.ui.PaddingMargin; import com.fr.form.ui.Widget; @@ -160,6 +155,7 @@ public class FormDesigner extends TargetComponent
implements TreeSelection // 编辑状态的事件表 private CreatorEventListenerTable edit; protected List designerActions; + protected List basicActions; private FormDesignerModeForSpecial desigerMode; private Action switchAction; private FormElementCaseContainerProvider elementCaseContainer; @@ -227,7 +223,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection public Parameter[] getNoRepeatParas(Parameter[] paras) { List paraList = new ArrayList(); - java.util.Set set = new java.util.HashSet(); + Set set = new java.util.HashSet(); for (Parameter p : paras) { if (!set.contains(p.getName().toLowerCase())) { paraList.add(p); @@ -252,7 +248,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection public void refreshParameter() { XLayoutContainer rootContainer = this.getParaComponent(); if (rootContainer != null) { - java.util.List namelist = new ArrayList(); + List namelist = new ArrayList(); rootContainer.getAllXCreatorNameList(rootContainer, namelist); // parameterArray是报表的所有参数, nameList是已经在参数面板添加过控件的参数名 // 与已有的参数列表比较 如果已经存在 就除去 @@ -1214,20 +1210,28 @@ public class FormDesigner extends TargetComponent implements TreeSelection public void startDraggingComponent(XCreator xCreator, MouseEvent lastPressEvent, int x, int y) { // 根据所选择的组件的BeanInfo生成相应的AddingModel // AddingModel和StateModel不一样,适合当前选择的组件相关的 - int creatorWidth = xCreator.getWidth(); - int creatorHeight = xCreator.getHeight(); this.addingModel = new AddingModel(xCreator, x, y); TransferHandler handler = new DesignerTransferHandler(this, addingModel); setTransferHandler(handler); handler.exportAsDrag(this, lastPressEvent, TransferHandler.COPY); - XCreator parent = XCreatorUtils.getParentXLayoutContainer(xCreator); - selectionModel.removeCreator(xCreator, creatorWidth, creatorHeight); - selectionModel.setSelectedCreator(parent); + XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator); + parent.getLayoutAdapter().dragStart(xCreator, selectionModel); this.setDropTarget(new FormCreatorDropTarget(this)); // 触发状态添加模式事件 repaint(); } + public void draggingComponent(int x, int y){ + XCreator xCreator = this.addingModel.getXCreator(); + XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator); + if (parent!= null && parent.getLayoutAdapter()!=null){ + parent.getLayoutAdapter().dragOver(xCreator, selectionModel, x, y); + } + + // 触发状态添加模式事件 + repaint(); + } + /** * 改变组件值 * @@ -1378,14 +1382,37 @@ public class FormDesigner extends TargetComponent implements TreeSelection */ public UpdateAction[] getActions() { if (designerActions == null) { - designerActions = new ArrayList(Arrays.asList(new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this), - new FormDeleteAction(this), new MoveToTopAction(this), new MoveToBottomAction(this), - new MoveUpAction(this), new MoveDownAction(this)})); + designerActions = new ArrayList(getBasicActions()); + designerActions.add(new MoveToTopAction(this)); + designerActions.add(new MoveToBottomAction(this)); + designerActions.add(new MoveUpAction(this)); + designerActions.add(new MoveDownAction(this)); dmlActions(designerActions); } return designerActions.toArray(new UpdateAction[designerActions.size()]); } + private List getBasicActions(){ + if (basicActions == null) { + basicActions = new ArrayList(); + basicActions.add(new CutAction(this)); + basicActions.add(new CopyAction(this)); + basicActions.add(new PasteAction(this)); + basicActions.add(new FormDeleteAction(this)); + } + return basicActions; + } + + public JComponent[] getBasicActionComponent() { + List actions = getBasicActions(); + int size = actions.size(); + JComponent[] jComponents = new JComponent[size]; + for (int i = 0; i < size; i++) { + jComponents[i] = actions.get(i).createToolBarComponentByName("Global_Toolbar"); + } + return jComponents; + } + /** * 扩展菜单项 * @@ -1404,16 +1431,34 @@ public class FormDesigner extends TargetComponent implements TreeSelection } } + private DesignerBaseOperate getLayoutBaseOperate(){ + FormSelection selection = this.getSelectionModel().getSelection(); + XCreator creator = selection.getSelectedCreator(); + XLayoutContainer container = (XLayoutContainer) creator.getParent(); + if (container == null) { + return new DefaultDesignerBaseOperate(); + } + return container.getLayoutAdapter().getDesignerBaseOperate(); + } + public boolean isCurrentComponentCutable() { - return !(isRootSelected() || isParameterSelected()); + DesignerBaseOperate designerBaseOperate = getLayoutBaseOperate(); + return !(isRootSelected() || isParameterSelected()) && designerBaseOperate.supportCutAction(); } public boolean isCurrentComponentCopyable() { - return !(isRootSelected() || isParameterSelected()); + DesignerBaseOperate designerBaseOperate = getLayoutBaseOperate(); + return !(isRootSelected() || isParameterSelected()) && designerBaseOperate.supportCopyAction(); } public boolean isCurrentComponentDeletable() { - return !isRootSelected(); + DesignerBaseOperate designerBaseOperate = getLayoutBaseOperate(); + return !isRootSelected() && designerBaseOperate.supportDeleteAction(); + } + + public boolean isCurrentComponentPastable() { + DesignerBaseOperate designerBaseOperate = getLayoutBaseOperate(); + return designerBaseOperate.supportPasteAction(); } // 当前选中控件可以上移一层吗? @@ -1469,6 +1514,10 @@ public class FormDesigner extends TargetComponent implements TreeSelection return formArea; } + public void switchBodyLayout(XLayoutContainer xLayoutContainer){ + formArea.switchBodyLayout(xLayoutContainer); + } + /** * 设置上层区域 * diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index 776925044..db5367ee9 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -210,10 +210,10 @@ public class FormDesignerUI extends ComponentUI { } XCreator bean = addingModel.getXCreator(); int x = addingModel.getCurrentX(); - int y = addingModel.getCurrentY(); + int y = addingModel.getCurrentY() ; - int width = bean.getWidth(); - int height = bean.getHeight(); + int width = bean.initEditorSize().width; + int height = bean.initEditorSize().height; Graphics clipg = g.create(x, y, width, height); ArrayList dbcomponents = new ArrayList(); // 禁止双缓冲行为 diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java index 5a3433917..ee7918e50 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java @@ -294,7 +294,6 @@ public class FormSelection { creator.setBackupBound(backupBounds); } layoutAdapter.fix(creator); - resetElementCaseImage(creator); } i++; } @@ -322,26 +321,6 @@ public class FormSelection { return false; } - /** - * @Description 重置报表块缩略图 - * @param: creator - * @return void - * @Author Henry.Wang - * @Date 2021/5/21 14:59 - **/ - public void resetElementCaseImage(XCreator creator) { - if (creator instanceof XWTitleLayout) { - XWTitleLayout xwTitleLayout = (XWTitleLayout) creator; - for (int i = 0; i < xwTitleLayout.getComponentCount(); i++) { - Component component = xwTitleLayout.getComponent(i); - if (component instanceof XElementCase) { - XElementCase xElementCase = (XElementCase) component; - xElementCase.updateECImage(); - } - } - } - } - /** * 检查下有没有参数面板,如果存在,处理下参数面板造成的偏移量 * @param rectangle diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormUndoState.java b/designer-form/src/main/java/com/fr/design/mainframe/FormUndoState.java index e4fb5b755..8a579b8d1 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormUndoState.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormUndoState.java @@ -14,6 +14,7 @@ public class FormUndoState extends BaseUndoState { private double widthValue; private double heightValue; private double slideValue; + private boolean isFixLayout; public FormUndoState(BaseJForm t, FormArea formArea) { super(t); @@ -31,6 +32,7 @@ public class FormUndoState extends BaseUndoState { this.widthValue = formArea.getWidthPaneValue(); this.heightValue = formArea.getHeightPaneValue(); this.slideValue = formArea.getSlideValue(); + this.isFixLayout = formArea.isFixLayout(); } /** @@ -89,6 +91,14 @@ public class FormUndoState extends BaseUndoState { return this.slideValue; } + /** + * 返回是否处于固定布局编辑状态下 + * @return + */ + public boolean isFixLayout(){ + return isFixLayout; + } + @Override public void applyState() { this.getApplyTarget().applyUndoState4Form(this); 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 ae488ff3b..89164154c 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 @@ -676,6 +676,7 @@ public class JForm extends JTemplate implements BaseJForm implements BaseJForm implements BaseJForm dbcomponents = new ArrayList(); // 禁止双缓冲 ComponentUtils.disableBuffer(creator, dbcomponents); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java b/designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java index 53bea9480..476afe8b6 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java @@ -251,7 +251,10 @@ public class CreateComponentAction extends UpdateAction { private Image componentToImage(Component comp, Rectangle rect) { - BufferedImage im = new BufferedImage((int) rect.getWidth(), (int) rect.getHeight(), BufferedImage.TYPE_INT_RGB); + BufferedImage im = new BufferedImage((int) rect.getWidth(), (int) rect.getHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = (Graphics2D)im.getGraphics(); + g2d.setColor(Color.WHITE); + g2d.fillRect(0, 0 , rect.width, rect.height); comp.paint(im.getGraphics()); return im; } @@ -260,7 +263,7 @@ public class CreateComponentAction extends UpdateAction { private Image moduleToImage(Form form, ElementCaseEditor editor, Map parameterMap, Rectangle rect) { if (editor == null) { - return new BufferedImage((int) rect.getWidth(), (int) rect.getHeight(), BufferedImage.TYPE_INT_RGB); + return new BufferedImage((int) rect.getWidth(), (int) rect.getHeight(), BufferedImage.TYPE_INT_ARGB); } FormElementCaseProvider provider = editor.getElementCase(); provider.setName(editor.getWidgetName()); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java index 72418b86b..0dd613975 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java @@ -61,7 +61,7 @@ public class ShareComponentUtils { boolean isCurrentUsingThemeSuitSharedComponent = StringUtils.isNotEmpty(theme.getName()) && StringUtils.isNotEmpty(suitableTemplateThemeName) && StringUtils.equals(theme.getName(), suitableTemplateThemeName); - XCreatorUtils.setupTemplateTheme(creator, (FormTheme) theme, isCurrentUsingThemeSuitSharedComponent ? TemplateThemeCompatible.NONE : TemplateThemeCompatible.ABSENT); + XCreatorUtils.setupTemplateTheme(creator, false, (FormTheme) theme, isCurrentUsingThemeSuitSharedComponent ? TemplateThemeCompatible.NONE : TemplateThemeCompatible.ABSENT); } return creator; } diff --git a/designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java b/designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java index 5f45b57b0..62eebdf21 100644 --- a/designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java @@ -10,6 +10,8 @@ import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.properties.PropertyTab; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.fit.DesignerUIModeConfig; +import com.fr.design.fit.common.TemplateTool; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.fun.ParameterExpandablePaneUIProvider; import com.fr.design.gui.ibutton.UIButtonGroup; @@ -20,8 +22,11 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.FormSelection; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.widget.accessibles.AccessibleBackgroundEditor; +import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.ui.designer.AbstractDataModify; import com.fr.design.widget.ui.designer.component.UIBoundSpinner; @@ -35,6 +40,7 @@ import javax.swing.Icon; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Rectangle; import java.util.Set; /** @@ -43,18 +49,19 @@ import java.util.Set; public class RootDesignDefinePane extends AbstractDataModify { private XWParameterLayout root; private UISpinner designerWidth; + private UISpinner paraHeight; private UICheckBox displayReport; private UICheckBox useParamsTemplate; private AccessibleBackgroundEditor background; private UIButtonGroup hAlignmentPane; private UITextField labelNameTextField; - /** - * 插件带来的额外属性 - */ + //是否是新设计模式下决策报表 + private boolean newForm; private PropertyGroupPane extraPropertyGroupPane; public RootDesignDefinePane(XCreator xCreator) { super(xCreator); + newForm = TemplateTool.getCurrentEditingNewJForm() != null && DesignerUIModeConfig.getInstance().newUIMode(); this.root = (XWParameterLayout) xCreator; initComponent(); } @@ -62,7 +69,11 @@ public class RootDesignDefinePane extends AbstractDataModify { public void initComponent() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - designerWidth = new UIBoundSpinner(1, Integer.MAX_VALUE, 1); + if (newForm) { + paraHeight = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0); + } else { + designerWidth = new UIBoundSpinner(1, Integer.MAX_VALUE, 1); + } JPanel advancePane = createAdvancePane(); UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane); this.add(advanceExpandablePane, BorderLayout.NORTH); @@ -70,7 +81,6 @@ public class RootDesignDefinePane extends AbstractDataModify { UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Size"), 280, 20, layoutPane); this.add(layoutExpandablePane, BorderLayout.CENTER); this.addExtraUIExpandablePaneFromPlugin(); - } private void addExtraUIExpandablePaneFromPlugin() { @@ -92,9 +102,9 @@ public class RootDesignDefinePane extends AbstractDataModify { double[] rowSize = {p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}}; - Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Desin_Width")), designerWidth}, - }; + Component[] component = newForm ? new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Design_Height")), paraHeight} : + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Desin_Width")), designerWidth}; + Component[][] components = new Component[][]{component}; JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); @@ -103,6 +113,21 @@ public class RootDesignDefinePane extends AbstractDataModify { } public JPanel createAdvancePane() { + if (newForm) { + return getNewFormAdvancePane(); + } else { + return getTemplateAdvancePane(); + } + } + + /** + * @Description: 获取的非新决策报表AdvancePane + * @param + * @return: + * @Author: Henry.Wang + * @date: 2020/11/05 15:36 + */ + private JPanel getTemplateAdvancePane() { JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); labelNameTextField = new UITextField(); displayReport = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Display_Nothing_Before_Query")); @@ -139,6 +164,40 @@ public class RootDesignDefinePane extends AbstractDataModify { return jPanel; } + /** + * @Description: 获取新决策报表的AdvancePane + * @param + * @return: + * @Author: Henry.Wang + * @date: 2020/11/05 15:36 + */ + private JPanel getNewFormAdvancePane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + labelNameTextField = new UITextField(); + displayReport = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Display_Nothing_Before_Query")); + UIComponentUtils.setLineWrap(displayReport); + useParamsTemplate = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Use_Params_Template")); + background = new AccessibleBackgroundEditor(); + + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p, p}; + double[] columnSize = {p, f}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}}; + Component[][] components = new Component[][]{ + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), background}, + new Component[]{displayReport, null}, + new Component[]{useParamsTemplate, null} + }; + JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); + panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); + + jPanel.add(panel, BorderLayout.NORTH); + + return jPanel; + } + @Override public String title4PopupWindow() { return "parameter"; @@ -150,17 +209,37 @@ public class RootDesignDefinePane extends AbstractDataModify { background.setValue(ob.getBackground()); displayReport.setSelected(ob.isDelayDisplayContent()); useParamsTemplate.setSelected(ob.isUseParamsTemplate()); - designerWidth.setValue(ob.getDesignWidth()); - hAlignmentPane.setSelectedItem(ob.getPosition()); + if (newForm) { + FormDesigner designer = TemplateTool.getCurrentEditingNewJForm().getFormDesign(); + paraHeight.setValue(designer.getParaHeight()); + } else { + designerWidth.setValue(ob.getDesignWidth()); + hAlignmentPane.setSelectedItem(ob.getPosition()); - if (extraPropertyGroupPane != null) { - extraPropertyGroupPane.populate(ob); + if (extraPropertyGroupPane != null) { + extraPropertyGroupPane.populate(ob); + } } } @Override public WParameterLayout updateBean() { + if (newForm) { + return updateNewFormBean(); + } else { + return updateTemplateBean(); + } + } + + /** + * @Description: 更新非新决策报表的bean + * @param + * @return: + * @Author: Henry.Wang + * @date: 2020/11/05 15:36 + */ + private WParameterLayout updateTemplateBean() { WParameterLayout wParameterLayout = (WParameterLayout) creator.toData(); wParameterLayout.setLabelName(labelNameTextField.getText()); if (isCompsOutOfDesignerWidth((int) designerWidth.getValue())) { @@ -173,22 +252,56 @@ public class RootDesignDefinePane extends AbstractDataModify { JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); jTemplate.needAddTemplateIdAttr(useParamsTemplate.isSelected()); wParameterLayout.setBackground((Background) background.getValue()); - wParameterLayout.setPosition((int) hAlignmentPane.getSelectedItem()); + wParameterLayout.setPosition((Integer) hAlignmentPane.getSelectedItem()); return wParameterLayout; } - private boolean isCompsOutOfDesignerWidth(int designerWidth){ - for(int i=0; i designerWidth){ + if (comp.getX() + comp.getWidth() > designerWidth) { return true; } } return false; } + @Override public DataCreatorUI dataUI() { return null; } - } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/PaddingBoundPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/PaddingBoundPane.java index 856ff6a0c..a73104e28 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/PaddingBoundPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/PaddingBoundPane.java @@ -14,6 +14,7 @@ import com.fr.form.ui.RichStyleWidgetProvider; import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; import java.awt.BorderLayout; import java.awt.Component; @@ -37,10 +38,10 @@ public class PaddingBoundPane extends BasicPane { public void initBoundPane(int t, int b, int l, int r) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - top = new UISpinner(0, Integer.MAX_VALUE, 1, t); - bottom = new UISpinner(0, Integer.MAX_VALUE, 1, b); - left = new UISpinner(0, Integer.MAX_VALUE, 1, l); - right = new UISpinner(0, Integer.MAX_VALUE, 1, r); + top = new UISpinner(0, Integer.MAX_VALUE, 1, t, false); + bottom = new UISpinner(0, Integer.MAX_VALUE, 1, b, false); + left = new UISpinner(0, Integer.MAX_VALUE, 1, l, false); + right = new UISpinner(0, Integer.MAX_VALUE, 1, r, false); top.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); bottom.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); left.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); @@ -79,13 +80,32 @@ public class PaddingBoundPane extends BasicPane { } public void update(RichStyleWidgetProvider marginWidget) { - marginWidget.setMargin(updateBean()); + try { + marginWidget.setMargin(updateBean()); + } catch (UnsupportedOperationException e) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + populateBean(marginWidget.getMargin()); + } + }); + + } + } public PaddingMargin updateBean() { return new PaddingMargin((int) top.getValue(), (int) left.getValue(), (int) bottom.getValue(), (int) right.getValue()); } + @Override + public void setEnabled(boolean enabled) { + this.top.setEnabled(enabled); + this.left.setEnabled(enabled); + this.bottom.setEnabled(enabled); + this.right.setEnabled(enabled); + } + @Override protected String title4PopupWindow() { return "PaddingBoundPane"; diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java index 87c89f3cb..e32bc9b07 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java @@ -5,6 +5,8 @@ import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.*; +import com.fr.design.fit.DesignerUIModeConfig; +import com.fr.design.fit.attrpane.PcFitExpandablePane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.style.FollowingThemePane; import com.fr.design.layout.FRGUIPaneFactory; @@ -15,12 +17,15 @@ import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.PaddingMargin; import com.fr.form.web.FormToolBarManager; import com.fr.general.ComparatorUtils; +import com.fr.report.fit.ReportFitAttr; import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; +import java.util.ArrayList; +import java.util.List; /** * Created by ibm on 2017/8/7. @@ -29,6 +34,9 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane 0) { + centerPane.add(extraPropertyGroupPane, BorderLayout.CENTER); + } + pcFitExpandablePane = new PcFitExpandablePane(this); + if (DesignerUIModeConfig.getInstance().newUIMode()) { + centerPane.add(pcFitExpandablePane, BorderLayout.SOUTH); + } + return centerPane; } + private CRPropertyDescriptor[] removeOldFitEditor(CRPropertyDescriptor[] extraTableEditor) { + if (!DesignerUIModeConfig.getInstance().newUIMode()) { + return extraTableEditor; + } + List list = new ArrayList(); + for (CRPropertyDescriptor crPropertyDescriptor : extraTableEditor) { + if (!ComparatorUtils.equals(FIT_STATE_PC, crPropertyDescriptor.getName())) { + list.add(crPropertyDescriptor); + } + } + return list.toArray(new CRPropertyDescriptor[list.size()]); + } + protected ElementCaseEditor updateSubBean() { ElementCaseEditor elementCaseEditor = (ElementCaseEditor) creator.toData(); if (themePane.isFollowingTheme() || ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) { paddingBoundPane.update(elementCaseEditor); } elementCaseEditor.setToolBars((FormToolBarManager[]) elementCaseToolBarEditor.getValue()); - + ReportFitAttr fitAttr = pcFitExpandablePane.update(); + elementCaseEditor.setReportFitAttr(fitAttr); return elementCaseEditor; } + protected void populateSubBean(ElementCaseEditor ob) { paddingBoundPane.populate(ob); elementCaseToolBarEditor.setValue(ob.getToolBars()); extraPropertyGroupPane.populate(ob); + pcFitExpandablePane.populate(ob.getReportFitAttr()); } - } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java index 442d872eb..d6d508a0a 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java @@ -11,6 +11,8 @@ import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.properties.items.FRLayoutTypeItems; import com.fr.design.designer.properties.items.Item; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; @@ -19,6 +21,8 @@ import com.fr.design.gui.xpane.LayoutStylePane; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor; import com.fr.design.widget.FRWidgetFactory; @@ -36,6 +40,12 @@ import javax.swing.DefaultComboBoxModel; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +import static javax.swing.JOptionPane.OK_CANCEL_OPTION; +import static javax.swing.JOptionPane.OK_OPTION; +import static javax.swing.JOptionPane.WARNING_MESSAGE; /** * Created by ibm on 2017/8/2. @@ -60,8 +70,9 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane { initUIComboBox(); this.setLayout(FRGUIPaneFactory.createBorderLayout()); boundPane = new WidgetBoundPane(creator); - this.add(boundPane, BorderLayout.NORTH); - + if (!DesignerUIModeConfig.getInstance().newUIMode()){ + this.add(boundPane, BorderLayout.NORTH); + } JPanel panel1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); this.add(panel1, BorderLayout.CENTER); @@ -118,12 +129,13 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane { UILabel layoutTypeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")); UILabel scaleModeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode")); - - JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane( - new Component[][]{ - {layoutTypeLabel, layoutCombox}, - {scaleModeLabel, comboBox} - }, + Component[][] components = DesignerUIModeConfig.getInstance().newUIMode() ? new Component[][]{ + {layoutTypeLabel, layoutCombox} + } : new Component[][]{ + {layoutTypeLabel, layoutCombox}, + {scaleModeLabel, comboBox} + }; + JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); contentPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); @@ -173,14 +185,27 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane { ((XWFitLayout) creator.getBackupParent()).toData().resetStyle(); if (state == WBodyLayoutType.FIT.getTypeValue()) { XWFitLayout xwFitLayout = ((XWFitLayout)creator.getBackupParent()); - xwFitLayout.switch2FitBodyLayout(creator); - WFitLayout wFitLayout = xwFitLayout.toData(); - // 切换布局类型时,保留body背景样式 - if (wFitLayout != null) { - wFitLayout.setBorderStyleFollowingTheme(layout.isBorderStyleFollowingTheme()); - wFitLayout.setBorderStyle(layout.getBorderStyle()); + int selVal = FineJOptionPane.showConfirmDialog( + DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Form_Layout_Switch_Tip"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), + OK_CANCEL_OPTION, + WARNING_MESSAGE + ); + if(OK_OPTION == selVal){ + xwFitLayout.switch2FitBodyLayout(creator); + WFitLayout wFitLayout = xwFitLayout.toData(); + // 切换布局类型时,保留body背景样式 + if (wFitLayout != null) { + wFitLayout.setBorderStyleFollowingTheme(layout.isBorderStyleFollowingTheme()); + wFitLayout.setBorderStyle(layout.getBorderStyle()); + } + copyLayoutAttr(layout, xwFitLayout.toData()); + }else { + this.layoutCombox.setSelectedIndex(1); } copyLayoutAttr(layout, xwFitLayout.toData()); + xwFitLayout.refreshStylePreviewEffect(); } } layout.setBorderStyleFollowingTheme(themePane.isFollowingTheme()); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteLayoutDefinePane.java index dff0e159a..ef82a81b6 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteLayoutDefinePane.java @@ -5,6 +5,7 @@ import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.properties.items.FRAbsoluteConstraintsItems; import com.fr.design.designer.properties.items.Item; +import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; @@ -39,7 +40,9 @@ public class FRAbsoluteLayoutDefinePane extends AbstractFRLayoutDefinePane 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator()) { - component = xCreator.getComponent(0); + Component component = xCreator.getComponent(0); component.setBounds(xCreator.getBounds()); } } - xwAbsoluteBodyLayout.add(component); + if (!xCreator.acceptType(XOccupiedLayout.class)){ + xwAbsoluteBodyLayout.add(xCreator); + } + } copyLayoutAttr(wFitLayout, xwAbsoluteBodyLayout.toData()); xWFitLayout.setBackupParent(xwAbsoluteBodyLayout); FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); formDesigner.getSelectionModel().setSelectedCreators( FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout})); + if (xwAbsoluteBodyLayout.toData() != null) { + xwAbsoluteBodyLayout.toData().setBorderStyleFollowingTheme(wAbsoluteBodyLayout.isBorderStyleFollowingTheme()); + xwAbsoluteBodyLayout.toData().setBorderStyle(wAbsoluteBodyLayout.getBorderStyle()); + } + xwAbsoluteBodyLayout.refreshStylePreviewEffect(); + if (xWFitLayout.toData() != null) { + xWFitLayout.toData().resetStyle(); + } + xWFitLayout.refreshStylePreviewEffect(); + formDesigner.switchBodyLayout(xwAbsoluteBodyLayout); + return layout; } } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); @@ -253,11 +293,28 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane { @@ -18,7 +18,7 @@ public class ReportEngineAttrAction extends ReportComponentAction { } protected void addShortCut(MenuDef exportMenuDef, MenuDef excelExportMenuDef) { - if (CptCompileUtil.isNewEngine(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 { @@ -749,7 +748,7 @@ public class JWorkBook extends JTemplate { */ @Override public ShortCut[] shortcut4TemplateMenu() { - boolean isNewEngine = CptCompileUtil.isNewEngine(this.getTarget(), getEditingFILE().getPath()); + boolean enableNewEngine = CptAndCptxCompatibilityUtil.isEngineXEnable(this.getTarget(), getEditingFILE().getPath()); ShortCut[] commonShortCut = ArrayUtils.addAll(new ShortCut[]{ new ReportWebAttrAction(this), new ReportExportAttrAction(this), @@ -760,7 +759,7 @@ 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 (isNewEngine){ + if (enableNewEngine){ return ArraysUtil.insert(commonShortCut, new CalculateAttrAction(this), 5); }else { return commonShortCut; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/CellElementEditPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/CellElementEditPane.java index e54d03443..4205ea152 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/CellElementEditPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/CellElementEditPane.java @@ -7,9 +7,15 @@ import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.itabpane.TitleChangeListener; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.cell.settingpane.AbstractCellAttrPane; +import com.fr.design.mainframe.cell.settingpane.CellExpandAttrPane; +import com.fr.design.mainframe.cell.settingpane.CellOtherSetPane; +import com.fr.design.mainframe.cell.settingpane.CellPresentPane; +import com.fr.design.mainframe.cell.settingpane.CellStylePane; import com.fr.design.mainframe.cell.settingpane.*; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.utils.DesignUtils; +import com.fr.design.utils.gui.AdjustWorkBookDefaultStyleUtils; import com.fr.general.ComparatorUtils; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; @@ -17,8 +23,11 @@ import com.fr.report.cell.CellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Dimension; import java.util.ArrayList; import java.util.List; @@ -112,6 +121,7 @@ public class CellElementEditPane extends BasicPane { CellElement cellElement = elementCase.getCellElement(cs.getColumn(), cs.getRow()); if (cellElement == null) { cellElement = DefaultThemedTemplateCellElementCase.createInstance(cs.getColumn(), cs.getRow()); + AdjustWorkBookDefaultStyleUtils.adjustCellElement(cellElement); //默认选中的是A1单元格,所以若是A1单元格没有加到列表时要加上,否则在聚合报表时会出错 if (cs.isSelectedOneCell(elementCasePane) && (cs.getColumn() + cs.getRow() == 0)) { elementCase.addCellElement((TemplateCellElement) cellElement); 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 5391d8d9e..43c66d8c8 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 @@ -153,10 +153,13 @@ public class FormElementCaseDesigner Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null; if (grid != null) { boolean oldTranslucent = grid.isTranslucent(); + boolean oldShowExtraGridLine = grid.isShowExtraGridLine(); // 截缩图图时grid需支持半透明,不能用默认白色填充画布,否则会遮挡组件样式背景 grid.setTranslucent(true); + grid.setShowExtraGridLine(false); grid.paint(g2d); grid.setTranslucent(oldTranslucent); + grid.setShowExtraGridLine(oldShowExtraGridLine); } } catch (Exception e) { diff --git a/designer-realize/src/main/java/com/fr/design/present/ConditionAttributesGroupPane.java b/designer-realize/src/main/java/com/fr/design/present/ConditionAttributesGroupPane.java index 4e06c9771..a74cf2d7a 100644 --- a/designer-realize/src/main/java/com/fr/design/present/ConditionAttributesGroupPane.java +++ b/designer-realize/src/main/java/com/fr/design/present/ConditionAttributesGroupPane.java @@ -7,6 +7,7 @@ import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.UIListControlPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.utils.gui.AdjustWorkBookDefaultStyleUtils; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.general.NameObject; import com.fr.grid.selection.CellSelection; @@ -83,6 +84,7 @@ public class ConditionAttributesGroupPane extends UIListControlPane { editCellElement = tplEC.getTemplateCellElement(cs.getColumn(), cs.getRow()); if (editCellElement == null) { editCellElement = DefaultThemedTemplateCellElementCase.createInstance(cs.getColumn(), cs.getRow()); + AdjustWorkBookDefaultStyleUtils.adjustCellElement(editCellElement); } SheetUtils.calculateDefaultParent(tplEC); // 不知道这行代码的作用,怕去掉之后会出问题,先放在这里 diff --git a/designer-realize/src/main/java/com/fr/design/report/LayerReportEnginePane.java b/designer-realize/src/main/java/com/fr/design/report/ReportEnginePane.java similarity index 95% rename from designer-realize/src/main/java/com/fr/design/report/LayerReportEnginePane.java rename to designer-realize/src/main/java/com/fr/design/report/ReportEnginePane.java index e744579d4..0b75780a1 100644 --- a/designer-realize/src/main/java/com/fr/design/report/LayerReportEnginePane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ReportEnginePane.java @@ -11,17 +11,14 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; -import com.fr.locale.InterProviderFactory; import com.fr.report.core.ReportUtils; import com.fr.report.stable.LayerReportAttr; import com.fr.report.worksheet.WorkSheet; - import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; -import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; @@ -34,7 +31,7 @@ import java.util.List; * @version 10.0 * Created on 2021/08/22 */ -public class LayerReportEnginePane extends BasicBeanPane { +public class ReportEnginePane extends BasicBeanPane { private static final int LABEL_HEIGHT = 55; private UICheckBox isClientPaging; private UICheckBox isShowDataNumber; @@ -43,12 +40,12 @@ public class LayerReportEnginePane extends BasicBeanPane { private WorkSheet worksheet; private List radioButtons = new ArrayList<>(2); - public LayerReportEnginePane(WorkSheet worksheet) { + public ReportEnginePane(WorkSheet worksheet) { this.worksheet = worksheet; this.initComponents(); } - public LayerReportEnginePane() { + public ReportEnginePane() { this(null); } @@ -165,8 +162,8 @@ public class LayerReportEnginePane extends BasicBeanPane { isPageQueryBox.setSelected(false); countPerPageEditor.setEnabled(false); } - radioButtons.get(0).setSelected(ob.isNewEngine()); - radioButtons.get(1).setSelected(!ob.isNewEngine()); + radioButtons.get(0).setSelected(ob.getEngineState() == LayerReportAttr.ENGINE_X ? true : false); + radioButtons.get(1).setSelected(ob.getEngineState() == LayerReportAttr.LINE_ENGINE ? true : false); } @Override @@ -179,7 +176,7 @@ public class LayerReportEnginePane extends BasicBeanPane { attr.setShowDataNumber(isShowDataNumber.isSelected()); for (int i = 0; i < radioButtons.size(); i++){ if (radioButtons.get(i).isSelected()){ - attr.setNewEngine((i == 0)); + attr.setEngineState(i); } } return attr; diff --git a/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java b/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java index 044f0a458..772c309c5 100644 --- a/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java +++ b/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java @@ -151,8 +151,6 @@ 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(); - if (isOnSeparatorLineIncludeZero(evt, tmpSize2, tmpIncreaseSize) || isOnNormalSeparatorLine(evt, tmpSize2)) { dragType = GridUtils.DRAG_CELL_SIZE; isDragPermited = true; @@ -412,7 +410,6 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { iterateScrollBar(ePane, evt, DRAG_ACTION); DynamicUnitList sizeList = getSizeList(report); -// int resolution = ScreenResolution.getScreenResolution(); this.setToolTipText2(this.createToolTipString(sizeList.get(dragIndex), sizeList.getRangeValue(0, dragIndex + 1))); } diff --git a/designer-realize/src/main/java/com/fr/grid/Grid.java b/designer-realize/src/main/java/com/fr/grid/Grid.java index 4b4683339..dad41264c 100644 --- a/designer-realize/src/main/java/com/fr/grid/Grid.java +++ b/designer-realize/src/main/java/com/fr/grid/Grid.java @@ -18,6 +18,7 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.mainframe.DesignOperationEvent; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.JTemplate; +import com.fr.design.utils.gui.AdjustWorkBookDefaultStyleUtils; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.event.EventDispatcher; @@ -136,6 +137,8 @@ public class Grid extends BaseGridComponent { // 截取缩略图时需透明(不能用默认白色填充),否则会遮挡组件样式的背景,其余情况的绘制可以用白色等默认颜色填充 private boolean isTranslucent = false; + // 是否绘制单元格内容区之外的网格线 + private boolean showExtraGridLine = true; public Grid(int resolution) { this.resolution = resolution; @@ -871,6 +874,7 @@ public class Grid extends BaseGridComponent { // 必须保证editingCellElement不是null。 if (editingCellElement == null) { editingCellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); + AdjustWorkBookDefaultStyleUtils.adjustCellElement(editingCellElement); } editorComponent = getCellEditingComp(); if (editorComponent == null) { @@ -1036,6 +1040,7 @@ public class Grid extends BaseGridComponent { if (editingCellElement == null) { editingCellElement = DefaultThemedTemplateCellElementCase.createInstance(editingColumn, editingRow); tplEC.addCellElement(editingCellElement); + AdjustWorkBookDefaultStyleUtils.adjustCellElement(editingCellElement); } if (setValue4EditingElement(newValue)) { shrinkToFit(tplEC); @@ -1469,4 +1474,12 @@ public class Grid extends BaseGridComponent { public void setTranslucent(boolean translucent) { isTranslucent = translucent; } + + public boolean isShowExtraGridLine() { + return showExtraGridLine; + } + + public void setShowExtraGridLine(boolean showExtraGridLine) { + this.showExtraGridLine = showExtraGridLine; + } } diff --git a/designer-realize/src/main/java/com/fr/grid/GridUI.java b/designer-realize/src/main/java/com/fr/grid/GridUI.java index 10934a7cc..431c6de1e 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUI.java @@ -10,12 +10,14 @@ import com.fr.base.background.ColorBackground; import com.fr.base.background.ImageFileBackground; import com.fr.base.iofile.attr.WatermarkAttr; import com.fr.base.vcs.DesignerMode; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.JTemplate; import com.fr.design.roleAuthority.ReportAndFSManagePane; +import com.fr.design.utils.gui.AdjustWorkBookDefaultStyleUtils; import com.fr.general.Background; import com.fr.general.ComparatorUtils; import com.fr.grid.selection.CellSelection; @@ -43,11 +45,12 @@ import com.fr.report.stable.ReportConstants; import com.fr.report.stable.ReportSettings; import com.fr.report.worksheet.FormElementCase; import com.fr.report.worksheet.WorkSheet; +import com.fr.stable.AssistUtils; import com.fr.stable.ColumnRow; import com.fr.stable.Constants; import com.fr.stable.script.CalculatorUtils; import com.fr.stable.unit.FU; -import com.fr.stable.AssistUtils; +import com.fr.stable.unit.UNIT; import com.fr.third.antlr.ANTLRException; import com.fr.third.guava.collect.HashMultimap; @@ -172,7 +175,7 @@ public class GridUI extends ComponentUI { // denny:画背景.Background Background background = reportSettings.getBackground(); - if (background != null) { + if (background != null && !DesignModeContext.isDuchampMode()) { // denny: except the ColorBackground and ImageBackground if (grid.isEnabled() && !(background instanceof ImageFileBackground)) { background.paint(g2d, this.back_or_selection_rect); @@ -185,7 +188,7 @@ public class GridUI extends ComponentUI { private void clearBackground(Graphics2D g2d, Grid grid) { if (grid.isEnabled()) { - g2d.setPaint(Color.WHITE); + g2d.setPaint(AdjustWorkBookDefaultStyleUtils.adjustBack(Color.WHITE)); } else { g2d.setPaint(UIManager.getColor("control")); } @@ -288,15 +291,25 @@ public class GridUI extends ComponentUI { } } } - GridRange gridRange = GridRange.range(grid.getHorizontalBeginValue(), horizontalEndValue, grid.getVerticalBeginValue(), verticalEndValue) + int xBeginIndex = grid.getHorizontalBeginValue(); + int xEndIndex = horizontalEndValue; + int yBeginIndex = grid.getVerticalBeginValue(); + int yEndIndex = verticalEndValue; + if (!grid.isShowExtraGridLine()) { + xBeginIndex = 0; + xEndIndex = Math.max(0, report.getColumnCount() - 1); + yBeginIndex = 0; + yEndIndex = Math.max(0, report.getRowCount() - 1); + } + GridRange gridRange = GridRange.range(xBeginIndex, xEndIndex, yBeginIndex, yEndIndex) .rangeList(rowHeightList, columnWidthList) .realSize(realWidth, realHeight); - new DrawVerticalLineHelper(gridRange, grid.isShowGridLine(), + new DrawVerticalLineHelper(gridRange, grid.isShowGridLine(), grid.isShowExtraGridLine(), isShowVerticalPaginateLine, paperPaintHeight, paginateLineList, resolution).iterateStart2End(g2d); - new DrawHorizontalLineHelper(gridRange, grid.isShowGridLine(), + new DrawHorizontalLineHelper(gridRange, grid.isShowGridLine(), grid.isShowExtraGridLine(), isShowHorizontalPaginateLine, paperPaintWidth, paginateLineList, resolution).iterateStart2End(g2d); } @@ -320,6 +333,7 @@ public class GridUI extends ComponentUI { protected GridRange gridRange; protected boolean showGridLine; + protected boolean showExtraGridLine; protected boolean showPaginateLine; protected double paperPaintSize; @@ -332,11 +346,12 @@ public class GridUI extends ComponentUI { protected static final double THRESHOLD = 1.0E-4D; - DrawLineHelper(GridRange gridRange, boolean showGridLine, + DrawLineHelper(GridRange gridRange, boolean showGridLine, boolean showExtraGridLine, boolean showPaginateLine, double paperPaintSize, List paginateLineList, int resolution) { this.gridRange = gridRange; this.showGridLine = showGridLine; + this.showExtraGridLine = showExtraGridLine; this.showPaginateLine = showPaginateLine; this.paperPaintSize = paperPaintSize; @@ -353,10 +368,10 @@ public class GridUI extends ComponentUI { private class DrawVerticalLineHelper extends DrawLineHelper { - DrawVerticalLineHelper(GridRange gridRange, boolean showGridLine, + DrawVerticalLineHelper(GridRange gridRange, boolean showGridLine, boolean showExtraGridLine, boolean showPaginateLine, double paperPaintSize, List paginateLineList, int resolution) { - super(gridRange, showGridLine, showPaginateLine, + super(gridRange, showGridLine, showExtraGridLine, showPaginateLine, paperPaintSize, paginateLineList, resolution); } @@ -372,51 +387,58 @@ public class GridUI extends ComponentUI { @Override protected void iterateStart2End(Graphics2D g2d) { - float rowHeight, paperYAxisSumSize = 0, yAxisSumSize = 0; + UNIT rowHeight, paperYAxisSumSize = FU.getInstance(0), maxXAxisSumSize = FU.getInstance(0), yAxisSumSize = FU.getInstance(0); for (int i = 0; i <= gridRange.yEndIndex; i++) { if (i == 0) { i = gridRange.yBeginIndex; for (int k = 0; k < gridRange.yBeginIndex; k++) { - rowHeight = gridRange.rowHeightList.get(k).toPixF(resolution); - - paperYAxisSumSize += rowHeight; - if (paperYAxisSumSize >= paperPaintSize) { + rowHeight = gridRange.rowHeightList.get(k); + paperYAxisSumSize = paperYAxisSumSize.add(rowHeight); + if (paperYAxisSumSize.toPixF(resolution) >= paperPaintSize) { paperYAxisSumSize = rowHeight; } } } - rowHeight = gridRange.rowHeightList.get(i).toPixF(resolution); - paperYAxisSumSize += rowHeight; + + rowHeight = gridRange.rowHeightList.get(i); + paperYAxisSumSize = paperYAxisSumSize.add(rowHeight); if (showGridLine) { - float columnWidth, xAxisSumSize = 0; + UNIT columnWidth, xAxisSumSize = FU.getInstance(0); for (int j = gridRange.xBeginIndex; j <= gridRange.xEndIndex; j++) { - columnWidth = gridRange.columnWidthList.get(j).toPixF(resolution); + columnWidth = gridRange.columnWidthList.get(j); if (!mergeCellElementTable.get(CellPosition.value(i - 1, j)).contains(CellPosition.BOTTOM)) { - tmpLine2D.setLine(xAxisSumSize, yAxisSumSize, xAxisSumSize + columnWidth, yAxisSumSize); + tmpLine2D.setLine(xAxisSumSize.toPixF(resolution), yAxisSumSize.toPixF(resolution), xAxisSumSize.add(columnWidth).toPixF(resolution), yAxisSumSize.toPixF(resolution)); g2d.draw(tmpLine2D); } - xAxisSumSize += columnWidth; + xAxisSumSize = xAxisSumSize.add(columnWidth); + } + if (xAxisSumSize.toPixF(resolution) > maxXAxisSumSize.toPixF(resolution)) { + maxXAxisSumSize = xAxisSumSize; } } - if (showPaginateLine && paperYAxisSumSize - paperPaintSize > THRESHOLD) { - paginateLineList.add(getPaginateLine2D((int) yAxisSumSize)); + if (showPaginateLine && paperYAxisSumSize.toPixF(resolution) - paperPaintSize > THRESHOLD) { + paginateLineList.add(getPaginateLine2D((int) yAxisSumSize.toPixF(resolution))); paperYAxisSumSize = rowHeight; } - yAxisSumSize += rowHeight; + yAxisSumSize = yAxisSumSize.add(rowHeight); } // paint 最后一个横线.. if (showGridLine) { - drawLastLine(g2d, (int) yAxisSumSize); + if (showExtraGridLine) { + drawLastLine(g2d, (int) yAxisSumSize.toPixF(resolution)); + } else { + GraphHelper.drawLine(g2d, 0, yAxisSumSize.toPixF(resolution), maxXAxisSumSize.toPixF(resolution), yAxisSumSize.toPixF(resolution)); + } } } } private class DrawHorizontalLineHelper extends DrawLineHelper { - DrawHorizontalLineHelper(GridRange gridRange, boolean showGridLine, + DrawHorizontalLineHelper(GridRange gridRange, boolean showGridLine, boolean showExtraGridLine, boolean showPaginateLine, double paperPaintSize, List paginateLineList, int resolution) { - super(gridRange, showGridLine, showPaginateLine, + super(gridRange, showGridLine, showExtraGridLine, showPaginateLine, paperPaintSize, paginateLineList, resolution); } @@ -432,40 +454,47 @@ public class GridUI extends ComponentUI { @Override protected void iterateStart2End(Graphics2D g2d) { - float columnWidth, paperXAxisSumSize = 0, xAxisSumSize = 0; + UNIT columnWidth, paperXAxisSumSize = FU.getInstance(0), maxYAxisSumSize = FU.getInstance(0), xAxisSumSize = FU.getInstance(0); for (int i = 0; i <= gridRange.xEndIndex; i++) { if (i == 0) { i = gridRange.xBeginIndex; for (int k = 0; k < gridRange.xBeginIndex; k++) { - columnWidth = gridRange.columnWidthList.get(k).toPixF(resolution); - paperXAxisSumSize += columnWidth; - if (paperXAxisSumSize >= paperPaintSize) { + columnWidth = gridRange.columnWidthList.get(k); + paperXAxisSumSize = paperXAxisSumSize.add(columnWidth); + if (paperXAxisSumSize.toPixF(resolution) >= paperPaintSize) { paperXAxisSumSize = columnWidth; } } } - columnWidth = gridRange.columnWidthList.get(i).toPixF(resolution); - paperXAxisSumSize += columnWidth; + columnWidth = gridRange.columnWidthList.get(i); + paperXAxisSumSize = paperXAxisSumSize.add(columnWidth); if (showGridLine) { - float rowHeight, yAxisSumSize = 0; + UNIT rowHeight, yAxisSumSize = FU.getInstance(0); for (int j = gridRange.yBeginIndex; j <= gridRange.yEndIndex; j++) { - rowHeight = gridRange.rowHeightList.get(j).toPixF(resolution); + rowHeight = gridRange.rowHeightList.get(j); if (!mergeCellElementTable.get(CellPosition.value(j, i - 1)).contains(CellPosition.RIGHT)) { - tmpLine2D.setLine(xAxisSumSize, yAxisSumSize, xAxisSumSize, yAxisSumSize + rowHeight); + tmpLine2D.setLine(xAxisSumSize.toPixF(resolution), yAxisSumSize.toPixF(resolution), xAxisSumSize.toPixF(resolution), yAxisSumSize.add(rowHeight).toPixF(resolution)); g2d.draw(tmpLine2D); } - yAxisSumSize += rowHeight; + yAxisSumSize = yAxisSumSize.add(rowHeight); + } + if (yAxisSumSize.toPixF(resolution) > maxYAxisSumSize.toPixF(resolution)) { + maxYAxisSumSize = yAxisSumSize; } } - if (showPaginateLine && paperXAxisSumSize - paperPaintSize > THRESHOLD) { - paginateLineList.add(getPaginateLine2D((int) xAxisSumSize)); + if (showPaginateLine && paperXAxisSumSize.toPixF(resolution) - paperPaintSize > THRESHOLD) { + paginateLineList.add(getPaginateLine2D((int) xAxisSumSize.toPixF(resolution))); paperXAxisSumSize = columnWidth; } - xAxisSumSize += columnWidth; + xAxisSumSize = xAxisSumSize.add(columnWidth); } // paint 最后一个横线.. if (showGridLine) { - drawLastLine(g2d, (int) xAxisSumSize); + if (showExtraGridLine) { + drawLastLine(g2d, (int) xAxisSumSize.toPixD(resolution)); + } else { + GraphHelper.drawLine(g2d, xAxisSumSize.toPixF(resolution), 0, xAxisSumSize.toPixF(resolution), maxYAxisSumSize.toPixF(resolution)); + } } } } diff --git a/designer-realize/src/main/java/com/fr/grid/dnd/ElementCasePaneDropTarget.java b/designer-realize/src/main/java/com/fr/grid/dnd/ElementCasePaneDropTarget.java index 8ec813b6f..979ed9731 100644 --- a/designer-realize/src/main/java/com/fr/grid/dnd/ElementCasePaneDropTarget.java +++ b/designer-realize/src/main/java/com/fr/grid/dnd/ElementCasePaneDropTarget.java @@ -5,6 +5,7 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.utils.gui.AdjustWorkBookDefaultStyleUtils; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.data.TableDataColumn; @@ -250,7 +251,7 @@ public class ElementCasePaneDropTarget extends DropTargetAdapter { cellExPandAttr.setDirection(Constants.TOP_TO_BOTTOM); if (curCellElement == null) { curCellElement = DefaultThemedTemplateCellElementCase.createInstance(cs.getColumn(), cs.getRow(), cs.getColumnSpan(), cs.getRowSpan(), newLinearDSColumn); - + AdjustWorkBookDefaultStyleUtils.adjustCellElement(curCellElement); report.addCellElement(curCellElement); } else { // marks:直接覆盖值 diff --git a/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java b/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java index 23dbc77f5..7a23a1396 100644 --- a/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java +++ b/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java @@ -383,8 +383,27 @@ public class CellSelection extends Selection { return false; } } - - ec.merge(row, row + rowSpan - 1, column, column + columnSpan - 1); + int rowStartIndex = row; + int rowEndIndex = row + rowSpan - 1; + int columnStartIndex = column; + int columnEndIndex = column + columnSpan - 1; + + // 合并已有单元格,还是新建单元格 + boolean hasCellElement = false; + for (int ri = rowStartIndex; ri <= rowEndIndex; ri++) { + for (int ci = columnStartIndex; ci <= columnEndIndex; ci++) { + CellElement ce = ec.getCellElement(ci, ri); + if (ce != null) { + hasCellElement = true; + break; + } + } + } + if (hasCellElement) { + ec.merge(row, row + rowSpan - 1, column, column + columnSpan - 1); + } else { + ec.addCellElement(DefaultThemedTemplateCellElementCase.createInstance(column, row, columnSpan, rowSpan, null), true); + } return true; } diff --git a/designer-realize/src/main/resources/com/fr/design/images/splash.png b/designer-realize/src/main/resources/com/fr/design/images/splash.png index 395d1d2a6..0535306e3 100644 Binary files a/designer-realize/src/main/resources/com/fr/design/images/splash.png and b/designer-realize/src/main/resources/com/fr/design/images/splash.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/images/splash@2x.png b/designer-realize/src/main/resources/com/fr/design/images/splash@2x.png index 1ef35c2b0..a284a5585 100644 Binary files a/designer-realize/src/main/resources/com/fr/design/images/splash@2x.png and b/designer-realize/src/main/resources/com/fr/design/images/splash@2x.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/images/splash_en.png b/designer-realize/src/main/resources/com/fr/design/images/splash_en.png index 42538c005..9e3cac419 100644 Binary files a/designer-realize/src/main/resources/com/fr/design/images/splash_en.png and b/designer-realize/src/main/resources/com/fr/design/images/splash_en.png differ diff --git a/designer-realize/src/main/resources/com/fr/design/images/splash_en@2x.png b/designer-realize/src/main/resources/com/fr/design/images/splash_en@2x.png index eaed5f1af..8e90c76e3 100644 Binary files a/designer-realize/src/main/resources/com/fr/design/images/splash_en@2x.png and b/designer-realize/src/main/resources/com/fr/design/images/splash_en@2x.png differ diff --git a/designer-realize/src/test/java/com/fr/design/mainframe/app/DesignerAppUtilsTest.java b/designer-realize/src/test/java/com/fr/design/mainframe/app/DesignerAppUtilsTest.java index c2f7ef769..46aa574e9 100644 --- a/designer-realize/src/test/java/com/fr/design/mainframe/app/DesignerAppUtilsTest.java +++ b/designer-realize/src/test/java/com/fr/design/mainframe/app/DesignerAppUtilsTest.java @@ -103,4 +103,4 @@ public class DesignerAppUtilsTest { Assert.assertEquals(1, pluginMarkerAdapters1.size()); pluginMarkerAdapters1.contains(PluginMarker.create("com.fr.plugin5","1")); } -} +} \ No newline at end of file