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 5 years ago
parent
commit
335487ca75
  1. 7
      designer-base/src/main/java/com/fr/design/fun/FormWidgetOptionProvider.java
  2. 5
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormWidgetOptionProvider.java
  3. 26
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java
  4. 19
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java

7
designer-base/src/main/java/com/fr/design/fun/FormWidgetOptionProvider.java

@ -16,4 +16,11 @@ public interface FormWidgetOptionProvider extends ParameterWidgetOptionProvider
*/
boolean isContainer();
/**
* 如果是布局容器要实现粘贴到容器中的操作
* @param t
* @param <T> 泛型参数 表示选中的组件 一般为FormSelection
*/
<T> void paste2Container(T t);
}

5
designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormWidgetOptionProvider.java

@ -25,4 +25,9 @@ public abstract class AbstractFormWidgetOptionProvider extends AbstractProvider
public boolean isContainer() {
return false;
}
@Override
public <T> void paste2Container(T t) {
// do nothing
}
}

26
designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java

@ -1,6 +1,7 @@
package com.fr.design.designer.beans.models;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.base.clipboard.ClipboardFilter;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter;
@ -19,11 +20,13 @@ import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.general.ComparatorUtils;
import com.fr.stable.ArrayUtils;
import java.awt.LayoutManager;
@ -31,6 +34,7 @@ import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Set;
/**
* 该model保存当前选择的组件和剪切版信息
@ -43,6 +47,7 @@ public class SelectionModel {
private FormDesigner designer;
private FormSelection selection;
private Rectangle hotspotBounds;
private FormWidgetOptionProvider provider;
public SelectionModel(FormDesigner designer) {
this.designer = designer;
@ -256,9 +261,30 @@ public class SelectionModel {
//绝对布局
Rectangle rec = selection.getSelctionBounds();
FormSelectionUtils.paste2Container(designer, container, clipboard, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y);
} else if (isExtraContainer(container)) {
provider.paste2Container(selection);
}
}
/**
* 扩展的容器布局
* @param container
* @return
*/
private boolean isExtraContainer(XLayoutContainer container) {
if (container != null) {
Set<FormWidgetOptionProvider> set = ExtraDesignClassManager.getInstance().getArray(FormWidgetOptionProvider.XML_TAG);
for (FormWidgetOptionProvider provider : set) {
if (provider.isContainer() && ComparatorUtils.equals(provider.appearanceForWidget(), selection.getSelectedCreator().getParent().getClass())) {
this.provider = provider;
return true;
}
}
}
return false;
}
/**
* 删除当前所有选择的组件
*/

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

@ -9,7 +9,6 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
@ -20,6 +19,7 @@ import com.fr.grid.selection.CellSelection;
import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.ReportHelper;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.stable.ColumnRow;
import com.fr.stable.StringUtils;
@ -56,6 +56,9 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
//默认值
private static final String DEFAULT_FORMULA = "=";
//正在编辑的单元格
private TemplateCellElement editingCellElement;
private DocumentListener documentListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
@ -102,19 +105,27 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
formulaButton.setPreferredSize(new Dimension(20, formulaTextField.getPreferredSize().height));
formulaButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
String text = formulaTextField.getText();
final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula();
formulaPane.populate(BaseFormula.createFormulaBuilder().build(text));
CellSelection cellSelection = (CellSelection) tc.getSelection();
editingCellElement = tc.getEditingElementCase().getTemplateCellElement(cellSelection.getColumn(), cellSelection.getRow());
Object object = editingCellElement.getValue();
if (object instanceof BaseFormula) {
formulaPane.populate((BaseFormula) object);
} else {
String text = formulaTextField.getText();
formulaPane.populate(BaseFormula.createFormulaBuilder().build(text));
}
formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
BaseFormula fm = formulaPane.update();
if (fm.getContent().length() <= 1) {
fm.setContent(DEFAULT_FORMULA);
formulaTextField.setText(DEFAULT_FORMULA);
} else {
formulaTextField.setText(fm.getContent());
}
editingCellElement.setValue(fm);
}
}).setVisible(true);
}

Loading…
Cancel
Save