Browse Source

Merge branch 'release/10.0' of https://code.fineres.com/scm/~qinghui.liu/design into release/10.0

feature/big-screen
Qinghui.Liu 4 years ago
parent
commit
00605f74f8
  1. 21
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java
  2. 12
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java
  3. 232
      designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java
  4. 48
      designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java
  5. 87
      designer-form/src/main/java/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java
  6. 4
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  7. 19
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  8. 19
      designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java

21
designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java

@ -1,21 +1,22 @@
package com.fr.design.data.datapane;
import com.fr.base.BaseUtils;
import com.fr.general.NameObject;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.gui.itree.refreshabletree.UserObjectRefreshJTree;
import com.fr.design.icon.IconPathConstants;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.Color;
import java.awt.Component;
/**
* TableData Tree
@ -31,6 +32,7 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
this.setCellRenderer(tableDataTreeCellRenderer);
this.setEditable(false);
}
// CellRenderer
private DefaultTreeCellRenderer tableDataTreeCellRenderer = new DefaultTreeCellRenderer() {
private static final long serialVersionUID = 1L;
@ -66,14 +68,7 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
this.setIcon(null);
this.setText(PENDING.toString());
}
// 这里新建一个Label作为render是因为JTree在动态刷新的时候,节点上render画布的的宽度不会变,会使得一部分比较长的数据显示为"..."
UILabel label = new UILabel();
label.setText(getText());
label.setIcon(getIcon());
Dimension dim = label.getPreferredSize();
dim.height += 2;
this.setSize(dim);
this.setPreferredSize(dim);
this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND);
this.setTextSelectionColor(Color.WHITE);
this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE);
@ -152,7 +147,7 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
/*
* p:获得选中的NameObject = name + tabledata.
*/
*/
public NameObject getSelectedNameObject() {
TreePath selectedTreePath = this.getSelectionPath();
if (selectedTreePath == null) {

12
designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java

@ -2,7 +2,6 @@ package com.fr.design.gui.itree.filetree;
import com.fr.base.FRContext;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.gui.itree.refreshabletree.RefreshableJTree;
import com.fr.design.i18n.Toolkit;
@ -14,13 +13,13 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
@ -79,14 +78,7 @@ public class EnvFileTree extends RefreshableJTree {
this.setIcon(null);
this.setText(PENDING.toString());
}
// 这里新建一个Label作为render是因为JTree在动态刷新的时候,节点上render画布的的宽度不会变,会使得一部分比较长的数据显示为"..."
UILabel label = new UILabel();
label.setText(getText());
label.setIcon(getIcon());
this.setSize(label.getPreferredSize());
Dimension dim = label.getPreferredSize();
dim.height += 2;
this.setPreferredSize(dim);
this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND);
this.setTextSelectionColor(Color.WHITE);
this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE);

232
designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java

@ -20,14 +20,18 @@ import com.fr.design.editor.editor.TextEditor;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
@ -37,31 +41,34 @@ import java.util.Map.Entry;
/**
* The dialog used to input parameter.
*
* @editor zhou
* @since 2012-3-26上午11:09:45
*/
public class ParameterInputPane extends BasicPane {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
*
*/
private static final long serialVersionUID = 1L;
// alex:保存编辑器对应的参数的名字
private java.util.Map<ValueEditorPane, String> editorNameMap; // Map<Editor, Name>
// alex:保存编辑器对应的参数的名字
private java.util.Map<ValueEditorPane,String> editorNameMap; // Map<Editor, Name>
private boolean allowBlank = true;
private boolean allowBlank = true;
private FlowTableLayoutHelper flowTableLayoutHelper;
/**
/**
* Constructor.
*/
public ParameterInputPane(ParameterProvider[] parameters) {
this.initComponents(parameters);
}
public ParameterInputPane(ParameterProvider[] parameters, boolean allowBlank) {
this.allowBlank = allowBlank;
this.initComponents(parameters);
}
public ParameterInputPane(ParameterProvider[] parameters, boolean allowBlank) {
this.allowBlank = allowBlank;
this.initComponents(parameters);
}
private void initComponents(ParameterProvider[] parameters) {
this.setLayout(new BorderLayout(0, 4));
@ -71,9 +78,9 @@ public class ParameterInputPane extends BasicPane {
this.add(new JScrollPane(contentPane), BorderLayout.CENTER);
contentPane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameters") + ":"));
FlowTableLayoutHelper flowTableLayoutHelper = new FlowTableLayoutHelper();
flowTableLayoutHelper = new FlowTableLayoutHelper();
editorNameMap = new java.util.HashMap<ValueEditorPane,String>();
editorNameMap = new java.util.HashMap<ValueEditorPane, String>();
//Parameter list.
java.util.List<String> nameAddedList = new java.util.ArrayList<String>(); // alex:已经加到界面中去的参数名
@ -83,12 +90,12 @@ public class ParameterInputPane extends BasicPane {
// alex:已经在界面中的参数,不加了
if (nameAddedList.contains(parameter.getName())) {
continue;
}
if(parameter instanceof StoreProcedureParameter
&& ((StoreProcedureParameter) parameter).getSchema() == StoreProcedureConstants.OUT) {
continue;
}
continue;
}
if (parameter instanceof StoreProcedureParameter
&& ((StoreProcedureParameter) parameter).getSchema() == StoreProcedureConstants.OUT) {
continue;
}
final Object pv = parameter.getValue();
Editor[] editors = makeEditorByValue(pv);
@ -100,135 +107,140 @@ public class ParameterInputPane extends BasicPane {
editPane.setPreferredSize(new Dimension(180, editPane.getPreferredSize().height));
String parameterDisplayName = parameter.getName();
if(StringUtils.isNotBlank(parameter.getName())) {
parameterDisplayName = parameter.getName();
if (StringUtils.isNotBlank(parameter.getName())) {
parameterDisplayName = parameter.getName();
}
contentPane.add(flowTableLayoutHelper.createLabelFlowPane(parameterDisplayName + ":", editPane));
//add editor to parameter hashtable.
initTextListener(textF);
initTextListener(textF);
this.editorNameMap.put(textF, parameter.getName());
nameAddedList.add(parameter.getName());
}
}
}
@Override
public void addNotify() {
super.addNotify();
// windows 高DPI下,使用getPreferredSize必须在添加到容器之后,否则得到的数值不准确,因此先放到这调整大小
flowTableLayoutHelper.adjustLabelWidth();
}
protected void initTextListener(ValueEditorPane textF) {
textF.getCurrentEditor().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified();
}
});
}
private Editor[] makeEditorByValue(Object pv) {
Editor[] editors = {null};
if (pv instanceof Integer) {
editors[0] = new IntegerEditor();
} else if (pv instanceof Double || pv instanceof Float) {
editors[0] = new DoubleEditor();
} else if (pv instanceof Float) {
editors[0] = new FloatEditor();
} else if (pv instanceof Date) {
editors[0] = new DateEditor(true, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Date"));
} else if (pv instanceof Boolean) {
editors[0] = new BooleanEditor();
} else if (pv instanceof BaseFormula) {
editors = ValueEditorPaneFactory.basicEditors();
} else {
editors[0] = new TextEditor();
}
return editors;
}
textF.getCurrentEditor().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified();
}
});
}
private Editor[] makeEditorByValue(Object pv) {
Editor[] editors = {null};
if (pv instanceof Integer) {
editors[0] = new IntegerEditor();
} else if (pv instanceof Double || pv instanceof Float) {
editors[0] = new DoubleEditor();
} else if (pv instanceof Float) {
editors[0] = new FloatEditor();
} else if (pv instanceof Date) {
editors[0] = new DateEditor(true, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Date"));
} else if (pv instanceof Boolean) {
editors[0] = new BooleanEditor();
} else if (pv instanceof BaseFormula) {
editors = ValueEditorPaneFactory.basicEditors();
} else {
editors[0] = new TextEditor();
}
return editors;
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameters");
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameters");
}
/**
* Update
*/
public Map<String,Object> update() {
public Map<String, Object> update() {
java.util.Map<String,Object> nameValueMap = new java.util.HashMap<String,Object>();
java.util.Map<String, Object> nameValueMap = new java.util.HashMap<String, Object>();
Iterator<Entry<ValueEditorPane, String>> entryIt = this.editorNameMap.entrySet().iterator();
while(entryIt.hasNext()) {
java.util.Map.Entry<ValueEditorPane, String> entry = entryIt.next();
ValueEditorPane editor = entry.getKey();
String parameterName = entry.getValue();
Iterator<Entry<ValueEditorPane, String>> entryIt = this.editorNameMap.entrySet().iterator();
while (entryIt.hasNext()) {
java.util.Map.Entry<ValueEditorPane, String> entry = entryIt.next();
ValueEditorPane editor = entry.getKey();
String parameterName = entry.getValue();
Object editorStringValue = editor.update();
nameValueMap.put(parameterName, editorStringValue);
}
Object editorStringValue = editor.update();
nameValueMap.put(parameterName, editorStringValue);
}
return nameValueMap;
return nameValueMap;
}
public void checkValid() throws Exception {
if (!allowBlank) {
boolean valid = true;
String error = "";
Iterator<Entry<ValueEditorPane, String>> entryIt = this.editorNameMap.entrySet().iterator();
while (entryIt.hasNext()) {
java.util.Map.Entry<ValueEditorPane, String> entry = entryIt.next();
ValueEditorPane editor = entry.getKey();
String parameterName = entry.getValue();
Object editorStringValue = editor.update();
if (editorStringValue == null || StringUtils.isEmpty(Utils.objectToString(editorStringValue))) {
valid = false;
error += parameterName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Not_Null_Des") + "\n";
}
}
if (!valid) {
throw new Exception(error);
}
}
}
public void checkValid() throws Exception {
if (!allowBlank) {
boolean valid = true;
String error = "";
Iterator<Entry<ValueEditorPane, String>> entryIt = this.editorNameMap.entrySet().iterator();
while (entryIt.hasNext()) {
java.util.Map.Entry<ValueEditorPane, String> entry = entryIt.next();
ValueEditorPane editor = entry.getKey();
String parameterName = entry.getValue();
Object editorStringValue = editor.update();
if (editorStringValue == null || StringUtils.isEmpty(Utils.objectToString(editorStringValue))) {
valid = false;
error += parameterName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Not_Null_Des") + "\n";
}
}
if (!valid) {
throw new Exception(error);
}
}
}
/**
* The class help to flowlayout components
*/
private static class FlowTableLayoutHelper {
private List<UILabel> labelList = new ArrayList<UILabel>();
private List<UILabel> labelList = new ArrayList<UILabel>();
public FlowTableLayoutHelper() {
}
public FlowTableLayoutHelper() {
}
public JPanel createLabelFlowPane(String text, JComponent comp) {
JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
public JPanel createLabelFlowPane(String text, JComponent comp) {
JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
UILabel textLabel = new UILabel(text);
centerPane.add(textLabel);
textLabel.setHorizontalAlignment(SwingConstants.LEFT);
UILabel textLabel = new UILabel(text);
centerPane.add(textLabel);
textLabel.setHorizontalAlignment(SwingConstants.LEFT);
this.labelList.add(textLabel);
centerPane.add(comp);
this.labelList.add(textLabel);
centerPane.add(comp);
return centerPane;
}
return centerPane;
}
public void adjustLabelWidth() {
int maxWidth = 0;
public void adjustLabelWidth() {
int maxWidth = 0;
for (int i = 0; i < labelList.size(); i++) {
maxWidth = Math.max(maxWidth, labelList.get(i).getPreferredSize().width);
}
for (int i = 0; i < labelList.size(); i++) {
maxWidth = Math.max(maxWidth, labelList.get(i).getPreferredSize().width);
}
for (int i = 0; i < labelList.size(); i++) {
UILabel label = labelList.get(i);
for (int i = 0; i < labelList.size(); i++) {
UILabel label = labelList.get(i);
Dimension labelDim = new Dimension(maxWidth, label.getPreferredSize().height);
Dimension labelDim = new Dimension(maxWidth, label.getPreferredSize().height);
label.setPreferredSize(labelDim);
label.setSize(labelDim);
label.setMinimumSize(labelDim);
}
}
label.setPreferredSize(labelDim);
label.setSize(labelDim);
label.setMinimumSize(labelDim);
}
}
}
}

48
designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java

@ -1,13 +1,13 @@
package com.fr.van.chart.drillmap.designer.data.comp;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper;
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper;
import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
@ -15,7 +15,6 @@ import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.Component;
import java.awt.Dimension;
import java.util.Enumeration;
/**
@ -23,7 +22,7 @@ import java.util.Enumeration;
*/
public class MapDataTree extends JTree {
public MapDataTree(TreeNode root){
public MapDataTree(TreeNode root) {
super();
this.setModel(model);
model.setRoot(root);
@ -49,54 +48,54 @@ public class MapDataTree extends JTree {
if (children.hasMoreElements()) {
DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement();
if(GEOJSONTreeHelper.getInstance().isSelectableTreeNode(child)){
if (GEOJSONTreeHelper.isSelectableTreeNode(child)) {
selectTreeNode(child, m_model);
}else{
} else {
setFirstChildTreeNode(child, m_model);
}
}
}
private void setFirstChildTreeNode(DefaultMutableTreeNode parent, DefaultTreeModel m_model){
private void setFirstChildTreeNode(DefaultMutableTreeNode parent, DefaultTreeModel m_model) {
Enumeration<TreeNode> children = parent.children();
if (children.hasMoreElements()){
if (children.hasMoreElements()) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) children.nextElement();
selectTreeNode(node, m_model);
}
}
public void changeRootNode(TreeNode node){
public void changeRootNode(TreeNode node) {
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel();
m_model.setRoot(node);
}
public String getSelectNodeJSONPath() {
if(this.getLastSelectedPathComponent() == null){
if (this.getLastSelectedPathComponent() == null) {
return StringUtils.EMPTY;
}
DefaultMutableTreeNode currentSel = (DefaultMutableTreeNode)this.getLastSelectedPathComponent();
DefaultMutableTreeNode currentSel = (DefaultMutableTreeNode) this.getLastSelectedPathComponent();
return CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(currentSel.getUserObject().toString());
}
//根据路径精确查找
public DefaultMutableTreeNode setSelectNodePath(String jsonUrl) {
if(StringUtils.isEmpty(jsonUrl) || CompatibleGEOJSONHelper.isDeprecated(jsonUrl)){
if (StringUtils.isEmpty(jsonUrl) || CompatibleGEOJSONHelper.isDeprecated(jsonUrl)) {
return null;
}
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode) m_model.getRoot();
Enumeration<TreeNode> els = root.postorderEnumeration();
while(els.hasMoreElements()){
while (els.hasMoreElements()) {
DefaultMutableTreeNode el = (DefaultMutableTreeNode) els.nextElement();
if(el == null || el.getUserObject() == null){
if (el == null || el.getUserObject() == null) {
return null;
}
String dirPath = el.getUserObject().toString();
String url = CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(dirPath);
String url = CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(dirPath);
//先equals再valid原因:valid 远程下实时去服务器看有没有json文件
if (ComparatorUtils.equals(jsonUrl, url) && GEOJSONTreeHelper.isValidDirPath(dirPath)) {
selectTreeNode(el, m_model);
@ -115,14 +114,7 @@ public class MapDataTree extends JTree {
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value;
String name = getPresentName(treeNode);
this.setText(name);
UILabel label = new UILabel();
label.setText(getText());
label.setIcon(getIcon());
this.setSize(label.getPreferredSize());
Dimension dim = label.getPreferredSize();
dim.height += 2;
this.setPreferredSize(dim);
this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
this.setBackgroundNonSelectionColor(UIConstants.NORMAL_BACKGROUND);
this.setForeground(UIConstants.FONT_COLOR);
this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE);
@ -131,25 +123,25 @@ public class MapDataTree extends JTree {
};
protected String getPresentName(DefaultMutableTreeNode treeNode) {
if(treeNode == null || treeNode.getUserObject() == null){
if (treeNode == null || treeNode.getUserObject() == null) {
return StringUtils.EMPTY;
}
return ChartGEOJSONHelper.getPresentNameWithPath(treeNode.getUserObject().toString());
}
//模糊搜索 深度优先.
public void search(String text){
if(StringUtils.isEmpty(text)){
public void search(String text) {
if (StringUtils.isEmpty(text)) {
return;
}
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode) m_model.getRoot();
Enumeration<TreeNode> els = root.postorderEnumeration();
while(els.hasMoreElements()){
while (els.hasMoreElements()) {
DefaultMutableTreeNode el = (DefaultMutableTreeNode) els.nextElement();
String path = el.getUserObject().toString();
String path = el.getUserObject().toString();
String fileName = ChartGEOJSONHelper.getPresentNameWithPath(path);
if (StringUtils.contains(fileName, text) && GEOJSONTreeHelper.isValidDirPath(path)) {
selectTreeNode(el, m_model);
@ -158,7 +150,7 @@ public class MapDataTree extends JTree {
}
}
public void selectTreeNode(DefaultMutableTreeNode node, DefaultTreeModel m_model){
public void selectTreeNode(DefaultMutableTreeNode node, DefaultTreeModel m_model) {
TreeNode[] nodes = m_model.getPathToRoot(node);
TreePath treePath = new TreePath(nodes);
setSelectionPath(treePath);

87
designer-form/src/main/java/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java

@ -3,60 +3,53 @@ package com.fr.design.designer.treeview;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.gui.ilable.UILabel;
import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import java.awt.Component;
import java.awt.Dimension;
public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer {
public ComponentTreeCellRenderer() {
}
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (value instanceof XCreator) {
String name = ((XCreator) value).toData().getWidgetName();
setText(name);
Icon icon = null;
try {
icon = XCreatorUtils.getCreatorIcon((XCreator) value);
} catch (Exception e) {
FineLoggerFactory.getLogger().info("{} has not icon or has been deleted", name);
}
if (icon != null) {
setIcon(icon);
}
}
UILabel label = new UILabel();
label.setText(getText());
label.setIcon(getIcon());
Dimension dim = label.getPreferredSize();
dim.height += 2;
this.setSize(dim);
this.setPreferredSize(dim);
this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND);
return this;
}
@Override
public Icon getClosedIcon() {
return getIcon();
}
@Override
public Icon getLeafIcon() {
return getIcon();
}
@Override
public Icon getOpenIcon() {
return getIcon();
}
public ComponentTreeCellRenderer() {
}
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (value instanceof XCreator) {
String name = ((XCreator) value).toData().getWidgetName();
setText(name);
Icon icon = null;
try {
icon = XCreatorUtils.getCreatorIcon((XCreator) value);
} catch (Exception e) {
FineLoggerFactory.getLogger().info("{} has not icon or has been deleted", name);
}
if (icon != null) {
setIcon(icon);
}
}
this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND);
return this;
}
@Override
public Icon getClosedIcon() {
return getIcon();
}
@Override
public Icon getLeafIcon() {
return getIcon();
}
@Override
public Icon getOpenIcon() {
return getIcon();
}
}

4
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -177,8 +177,8 @@ public class EditingMouseListener extends MouseInputAdapter {
if (designer.isDrawLineMode()) {
designer.updateDrawLineMode(e);
} else {
int relativeX = Math.max(0, designer.getRelativeX(e.getX()));
int relativeY = Math.max(0, designer.getRelativeY(e.getY()));
int relativeX = Math.max(0, e.getX());
int relativeY = Math.max(0, e.getY());
if (selectionModel.hasSelectionComponent()
&& selectionModel.getSelection().getRelativeBounds().contains(

19
designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java

@ -22,10 +22,12 @@ import com.fr.form.main.parameter.FormParameterUI;
import com.fr.page.WatermarkPainter;
import com.fr.report.core.ReportUtils;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
@ -41,6 +43,8 @@ import java.util.ArrayList;
*/
public class FormDesignerUI extends ComponentUI {
private static final Color DESIGNER_BORDER_COLOR = new Color(198, 198, 198);
// 当前的设计器
private FormDesigner designer;
private SelectionModel selectionModel;
@ -90,7 +94,7 @@ public class FormDesignerUI extends ComponentUI {
designer.getDrawLineHelper().drawAuxiliaryLine(g);
return;
}
paintBorder(g);
paintSelection(g);
if (DesignerMode.isAuthorityEditing()) {
@ -275,6 +279,19 @@ public class FormDesignerUI extends ComponentUI {
clipg.dispose();
}
public void paintBorder(Graphics g) {
Rectangle bounds = designer.getTopContainer().getBounds();
bounds.x = -designer.getHorizontalScaleValue();
bounds.y = -designer.getVerticalScaleValue();
Graphics clipg = g.create();
clipg.clipRect(bounds.x, bounds.y, bounds.width, bounds.height);
Color oldColor = g.getColor();
g.setColor(DESIGNER_BORDER_COLOR);
GraphHelper.draw(g, bounds, Constants.LINE_THIN);
clipg.dispose();
g.setColor(oldColor);
}
/**
* 画出当前选择拖拽状态框
*

19
designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java

@ -3,11 +3,12 @@ package com.fr.quickeditor;
import com.fr.base.GraphHelper;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.CellElementPropertyPane;
@ -48,7 +49,7 @@ import java.util.ArrayList;
*/
public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
protected static final Dimension LABEL_DIMENSION = new Dimension(60, 20);
protected static final Dimension LABEL_DIMENSION = new Dimension(GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")), 20);
protected static final int VGAP = 10, HGAP = 8, VGAP_INNER = 3;
/**
@ -165,7 +166,7 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
columnRowTextField.setText(columnRow.toString());
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow());
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jTemplate != null) {
comboBox.removeActionListener(comboBoxActionListener);
comboBox.removeAllItems();
@ -208,10 +209,10 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
private JPanel initTopContent() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {GraphHelper.getWidth(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")), f};
double[] columnSize = {GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")), f};
double[] rowSize = {p, p};
UILabel cellLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cell"));
UILabel insertContentLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element"));
UILabel cellLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Cell"));
UILabel insertContentLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element"));
initCellElementEditComboBox();
Component[][] components = new Component[][]{
new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()},
@ -263,7 +264,7 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
* 初始化添加按钮
*/
private void initCellElementEditComboBox() {
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jTemplate == null) {
comboBox = new UIComboBox();
return;
@ -304,8 +305,8 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
ColumnRow columnRowEdit = ColumnRow.valueOf(columnRowTextField.getText());
// barry:检查输入是否正确
if (!ColumnRow.validate(columnRowEdit)) {
Object[] options = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK")};
JOptionPane.showOptionDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Please_Input_Letters+Numbers(A1,AA1,A11....)"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Warning"),
Object[] options = {Toolkit.i18nText("Fine-Design_Report_OK")};
JOptionPane.showOptionDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Please_Input_Letters+Numbers(A1,AA1,A11....)"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Warning"),
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
// 重新选中当前的selection,把columnRowTextField
tc.setSelection(tc.getSelection());

Loading…
Cancel
Save