Browse Source

Merge branch 'release/10.0' of ssh://cloud.finedevelop.com:7999/~lanlan/design into release/10.0

zheng-1641779399395
Lanlan 3 years ago
parent
commit
5aba0add28
  1. 3
      designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java
  2. 25
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java
  3. 27
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java
  4. 2
      designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java
  5. 12
      designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java
  6. 4
      designer-base/src/main/java/com/fr/design/login/DesignerLoginHelper.java
  7. 2
      designer-base/src/main/java/com/fr/design/login/DesignerLoginShowDialog.java
  8. 2
      designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java
  9. 6
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  10. 4
      designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java
  11. 7
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  12. 13
      designer-base/src/main/java/com/fr/design/mainframe/TabChangeListener.java
  13. 38
      designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java
  14. 3
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  15. 9
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  16. 30
      designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java
  17. 26
      designer-base/src/main/java/com/fr/env/CheckServiceDialog.java
  18. 8
      designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java
  19. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_e.png
  20. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_n.png
  21. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_ne.png
  22. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_nw.png
  23. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_s.png
  24. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_se.png
  25. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_sw.png
  26. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_w.png
  27. 12
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java
  28. 7
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  29. 2
      designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java
  30. 120
      designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java
  31. 3
      designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java
  32. 38
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  33. 8
      designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java
  34. 14
      designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java
  35. 23
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  36. 61
      designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java
  37. 26
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  38. 17
      designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java
  39. 14
      designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java
  40. 386
      designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java
  41. 15
      designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java
  42. 122
      designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java
  43. 59
      designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java
  44. 29
      designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java
  45. 31
      designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java
  46. 3
      designer-form/src/main/java/com/fr/design/mainframe/CoverReportPane.java
  47. 52
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  48. 12
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  49. 14
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  50. 26
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  51. 11
      designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java
  52. 30
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  53. 18
      designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java
  54. 4
      designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java
  55. 6
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/UIBoundSpinner.java
  56. 70
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java
  57. 2
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java
  58. 16
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  59. 42
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java
  60. 53
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java
  61. 33
      designer-realize/src/main/java/com/fr/design/share/SharableManager.java
  62. 17
      designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java
  63. 11
      designer-realize/src/main/java/com/fr/grid/Grid.java
  64. 18
      designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java
  65. 6
      designer-realize/src/main/java/com/fr/grid/GridUI.java

3
designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java

@ -27,6 +27,8 @@ public class PluginClassRefreshManager {
private final PluginEventListener pluginAfterRunEventListener = new PluginEventListener() {
@Override
public void on(PluginEvent event) {
// 重载模版之前 触发下hide
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange();
// 兼容之前版本特性
for (String tag : context) {
if (event.getContext().contain(tag)) {
@ -51,6 +53,7 @@ public class PluginClassRefreshManager {
public void on(PluginEvent event) {
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, pluginAfterRunEventListener);
if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) {
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange();
HistoryTemplateListCache.getInstance().reloadAllEditingTemplate();
}
}

25
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java

@ -158,7 +158,7 @@ public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> imp
private JToolBar creatToolBar() {
ToolBarDef toolBarDef = new ToolBarDef();
toolBarDef.addShortCut(new PreviewAction());
toolBarDef.addShortCut(new PreviewAction(this));
toolBarDef.addShortCut(new RefreshAction());
toolBarDef.addShortCut(SeparatorDef.DEFAULT);
isShareCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Is_Share_DBTableData"));
@ -243,7 +243,7 @@ public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> imp
this.storeProcedureWorkerListener = null;
}
private StoreProcedure updateBeanWithOutExecute() {
String dbName = connectionTableProcedurePane.getSelectedDatabaseConnnectonName();
@ -266,16 +266,16 @@ public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> imp
return sp;
}
@Override
public StoreProcedure updateBean() {
final StoreProcedure sp = updateBeanWithOutExecute();
if (updateWorker != null) {
updateWorker.cancel(true);
}
updateWorker = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER);
@ -284,7 +284,7 @@ public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> imp
sp.refreshDataModelListAndResultNames(dataModels);
return null;
}
@Override
public void done() {
DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER);
@ -293,7 +293,7 @@ public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> imp
fireDSChanged();
}
};
updateWorker.execute();
return sp;
}
@ -359,17 +359,20 @@ public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> imp
}
private class PreviewAction extends UpdateAction {
public PreviewAction() {
ProcedureDataPane procedureDataPane;
public PreviewAction(ProcedureDataPane procedureDataPane) {
this.setName(PREVIEW_BUTTON);
this.setMnemonic('P');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png"));
this.procedureDataPane = procedureDataPane;
}
@Override
public void actionPerformed(ActionEvent evt) {
StoreProcedure sp = updateBeanWithOutExecute();
StoreProcedureDataWrapper storeProcedureDataWrappe = new StoreProcedureDataWrapper(sp, StringUtils.EMPTY, queryText.getText());
storeProcedureDataWrappe.previewData(StoreProcedureDataWrapper.PREVIEW_ALL);
StoreProcedure sp = updateBeanWithOutExecute();
StoreProcedureDataWrapper storeProcedureDataWrapper = new StoreProcedureDataWrapper(this.procedureDataPane, sp, StringUtils.EMPTY, queryText.getText());
storeProcedureDataWrapper.previewData(StoreProcedureDataWrapper.PREVIEW_ALL);
}
}

27
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java

@ -18,6 +18,7 @@ import com.fr.log.FineLoggerFactory;
import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.SwingWorker;
import java.awt.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -52,16 +53,25 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
private int previewModel;
public StoreProcedureDataWrapper(StoreProcedure storeProcedure, String storeprocedureName, String dsName) {
this(storeProcedure, storeprocedureName, dsName, true);
this(null, storeProcedure, storeprocedureName, dsName, true);
}
public StoreProcedureDataWrapper(StoreProcedure storeProcedure, String storeprocedureName, String dsName, boolean needLoad) {
this(null, storeProcedure, storeprocedureName, dsName, needLoad);
}
public StoreProcedureDataWrapper(Component component, StoreProcedure storeProcedure, String storeprocedureName, String dsName) {
this(component, storeProcedure, storeprocedureName, dsName, true);
}
/**
* @param dsName 存储过程一个返回数据集的名字
* @param storeProcedure 存储过程
* @param storeprocedureName 存储过程的名字(某些情况下可以为空)
*/
public StoreProcedureDataWrapper(StoreProcedure storeProcedure, String storeprocedureName, String dsName, boolean needLoad) {
* @param: component loadingBar的父弹框如果不设置父弹框的话可能出现loadingBar隐藏在一个弹框后的情况
* @param: storeProcedure 存储过程
* @param: storeprocedureName 存储过程的名字(某些情况下可以为空)
* @param: dsName 存储过程一个返回数据集的名字
* @param: needLoad 是否要加载
**/
public StoreProcedureDataWrapper(Component component, StoreProcedure storeProcedure, String storeprocedureName, String dsName, boolean needLoad) {
this.dsName = dsName;
this.storeProcedure = storeProcedure;
this.storeProcedure.setCalculating(false);
@ -69,7 +79,10 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
if (needLoad) {
setWorker();
}
loadingBar = new AutoProgressBar(new JFrame(), Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) {
if (component == null) {
component = new JFrame();
}
loadingBar = new AutoProgressBar(component, Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) {
public void doMonitorCanceled() {
getWorker().cancel(true);
}

2
designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java

@ -399,6 +399,8 @@ public class PluginWebBridge {
if (uiDialog != null) {
uiDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
uiDialog.setVisible(false);
}
if (uiDialog == DesignerPluginContext.getPluginDialog()) {
DesignerPluginContext.setPluginDialog(null);
}
}

12
designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java

@ -58,7 +58,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
* Spinner内的数字文本框长度
*/
private int numberFieldColumns;
private boolean hasTextFieldFocus = false;
private boolean textFieldFocus = false;
public UISpinner() {
@ -197,6 +197,10 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
this.nextButton.setEnabled(flag);
}
public void setTextFieldFocus(boolean textFieldFocus) {
this.textFieldFocus = textFieldFocus;
}
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
@ -319,7 +323,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (hasTextFieldFocus && isEnabled() && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
if (textFieldFocus && isEnabled() && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
setValue(value - e.getWheelRotation());
}
}
@ -333,12 +337,12 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
textField.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
hasTextFieldFocus = true;
textFieldFocus = true;
}
@Override
public void focusLost(FocusEvent e) {
hasTextFieldFocus = false;
textFieldFocus = false;
textField.getDocument().removeDocumentListener(docListener);
textField.setValue(value);
textField.getDocument().addDocumentListener(docListener);

4
designer-base/src/main/java/com/fr/design/login/DesignerLoginHelper.java

@ -6,6 +6,7 @@ import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.plugin.DesignerPluginContext;
import com.fr.design.update.ui.dialog.UpdateMainDialog;
import com.fr.general.GeneralContext;
import java.awt.Dialog;
@ -25,7 +26,7 @@ import javax.swing.WindowConstants;
public class DesignerLoginHelper {
private static final String MAIN_RESOURCE_PATH = "/com/fr/design/login/login.html";
private static final String JXBROWSER = "com.teamdev.jxbrowser.chromium.Browser";
private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser";
private static UIDialog dialog = null;
@ -91,6 +92,7 @@ public class DesignerLoginHelper {
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dialog.setVisible(false);
dialog = null;
DesignerPluginContext.setPluginDialog(null);
}
}

2
designer-base/src/main/java/com/fr/design/login/DesignerLoginShowDialog.java

@ -1,6 +1,7 @@
package com.fr.design.login;
import com.fr.design.dialog.UIDialog;
import com.fr.design.plugin.DesignerPluginContext;
import com.fr.design.utils.gui.GUICoreUtils;
import java.awt.BorderLayout;
import java.awt.Component;
@ -36,6 +37,7 @@ public class DesignerLoginShowDialog extends UIDialog {
setSize(DEFAULT);
GUICoreUtils.centerWindow(this);
setResizable(false);
DesignerPluginContext.setPluginDialog(this);
}
@Override

2
designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java

@ -22,7 +22,7 @@ import javax.swing.WindowConstants;
public class DesignerGuideHelper {
private static final String MAIN_RESOURCE_PATH = "/com/fr/design/login/guide.html";
private static final String JXBROWSER = "com.teamdev.jxbrowser.chromium.Browser";
private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser";
private static final long ONE_WEEK = 7 * 24 * 3600 * 1000L;
private static final long ONE_MONTH = 30 * 24 * 3600 * 1000L;
private static final long SIX_MONTH = 6 * ONE_MONTH;

6
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -212,6 +212,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
}
@Override
public void windowIconified(WindowEvent e) {
// 最小化时 hide工具栏
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange();
}
};
private JComponent closeButton = new JComponent() {

4
designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java

@ -56,6 +56,10 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
} else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing()) {
DesignModeContext.switchTo(DesignerMode.NORMAL);
}
// 切换时
if (component != null) {
component.fireTabChange();
}
DesignerFrameFileDealerPane.getInstance().setCurrentEditingTemplate(jt);
if (component != null) {
layeredPane.remove(component);

7
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -95,7 +95,7 @@ import java.util.concurrent.Callable;
/**
* 报表设计和表单设计的编辑区域(设计器编辑的IO文件)
*/
public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave {
public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave, TabChangeListener {
// TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null
private static final int PREFIX_NUM = 3000;
protected FILE editingFILE = null;
@ -218,6 +218,11 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
}
}
@Override
public void fireTabChange() {
// do nothing
}
protected <R> void addPane(PropertyItemPaneProvider provider) {
// do nothing
}

13
designer-base/src/main/java/com/fr/design/mainframe/TabChangeListener.java

@ -0,0 +1,13 @@
package com.fr.design.mainframe;
/**
* tab切换时对当前打开的模版处理些事件
*
* @author hades
* @version 10.0
* Created by hades on 2021/7/22
*/
public interface TabChangeListener {
void fireTabChange();
}

38
designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java

@ -10,16 +10,20 @@ import java.awt.RenderingHints;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.AbstractButton;
import javax.swing.JPanel;
import javax.swing.border.AbstractBorder;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import javax.swing.plaf.ButtonUI;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.stable.Constants;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.design.style.background.BackgroundJComponent;
import com.fr.stable.Constants;
/**
* @author kunsnat E-mail:kunsnat@gmail.com
@ -29,7 +33,7 @@ import com.fr.design.style.background.BackgroundJComponent;
public abstract class AbstractSelectBox<T> extends AbstractPopBox implements MouseListener {
private static final long serialVersionUID = 2355250206956896774L;
private UIToggleButton triggleButton;
private UIButton triggleButton;
protected void initBox(int preWidth) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -37,8 +41,34 @@ public abstract class AbstractSelectBox<T> extends AbstractPopBox implements Mou
displayComponent = new BackgroundJComponent();
displayComponent.setEmptyBackground();
displayComponent.setBorder(new TriggleLineBorder());
triggleButton = new UIToggleButton(UIConstants.ARROW_DOWN_ICON);
triggleButton = new UIButton(UIConstants.ARROW_DOWN_ICON) {
public boolean shouldResponseChangeListener() {
return false;
}
@Override
public ButtonUI getUI() {
return new UIButtonUI() {
@Override
protected boolean isPressed(AbstractButton b) {
return model.isArmed() && model.isPressed();
}
@Override
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), UIConstants.COMBOBOX_BTN_PRESS);
} else if (isRollOver(b)) {
GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), UIConstants.COMBOBOX_BTN_ROLLOVER);
} else if (b.isNormalPainted()) {
GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), UIConstants.COMBOBOX_BTN_NORMAL);
}
}
};
}
};
triggleButton.setPreferredSize(new Dimension(20, 20));
triggleButton.setRoundBorder(true, Constants.LEFT);
JPanel displayPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
displayPane.add(displayComponent, BorderLayout.CENTER);

3
designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

@ -15,7 +15,6 @@ import com.fr.event.Listener;
import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.stable.os.OperatingSystem;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
@ -32,7 +31,7 @@ public class UpmFinder {
private static final String UPM_DIR = "/upm";
private static final String MAIN_RESOURCE_PATH = UPM_DIR + "/plugin_design.html";
private static final String JXBROWSER = OperatingSystem.isWindows() ? "com.teamdev.jxbrowser.browser.Browser" : "com.teamdev.jxbrowser.chromium.Browser";
private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser";
public static String installHome = FRContext.getCommonOperator().getWebRootPath();

9
designer-base/src/main/java/com/fr/design/utils/DesignUtils.java

@ -10,6 +10,7 @@ import com.fr.design.fun.DesignerEnvProcessor;
import com.fr.design.gui.UILookAndFeel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.ui.util.UIUtil;
import com.fr.exit.DesignerExiter;
import com.fr.file.FileFILE;
import com.fr.general.ComparatorUtils;
@ -205,7 +206,13 @@ public class DesignUtils {
isMatch = isMatch || path.endsWith(suffix);
}
if (isMatch) {
DesignerContext.getDesignerFrame().openTemplate(new FileFILE(f));
// ui线程作为打开入口
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
DesignerContext.getDesignerFrame().openTemplate(new FileFILE(f));
}
});
}
}
}

30
designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java

@ -26,6 +26,8 @@ import com.fr.plugin.manage.control.PluginTaskCallback;
import com.fr.plugin.manage.control.PluginTaskResult;
import com.fr.plugin.manage.control.ProgressCallback;
import com.fr.report.ReportHelper;
import com.fr.rpc.ExceptionHandler;
import com.fr.rpc.RPCInvokerExceptionInfo;
import com.fr.rpc.Result;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
@ -35,6 +37,7 @@ import com.fr.workspace.engine.base.FineObjectPool;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import com.fr.workspace.engine.exception.WorkspaceConnectionException;
import com.fr.workspace.engine.rpc.WorkspaceProxyPool;
import com.fr.workspace.server.check.VersionInfoOperator;
import java.lang.reflect.Method;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
@ -160,15 +163,22 @@ public class VersionCheckUtils {
}
public static String getRemoteBranch(DesignerWorkspaceInfo selectedEnv) {
String remoteBranch = StringUtils.EMPTY;
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection();
try {
remoteBranch = new FunctionalHttpRequest(connectionInfo).getServerBranch();
} catch (WorkspaceConnectionException e) {
remoteBranch = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old") + formatBranch(GeneralUtils.readFullBuildNO());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
String remoteBranch;
remoteBranch = WorkContext.getCurrent().get(VersionInfoOperator.class, new ExceptionHandler<String>() {
@Override
public String callHandler(RPCInvokerExceptionInfo exceptionInfo) {
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection();
String remoteBranch = StringUtils.EMPTY;
try {
remoteBranch = new FunctionalHttpRequest(connectionInfo).getServerBranch();
} catch (WorkspaceConnectionException e) {
remoteBranch = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old") + formatBranch(GeneralUtils.readFullBuildNO());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return remoteBranch;
}
}).getFullBuildNO();
return remoteBranch;
}
@ -252,7 +262,7 @@ public class VersionCheckUtils {
Map<String, String> pluginsNameMap = ReportHelper.getPluginNameMap();
for (int i = 0; i < remotePlugins.size(); i++) {
remotePlugin = remotePlugins.getJSONObject(i);
if (ComparatorUtils.equals(remotePlugin.getString("running"), "false")) {
if (ComparatorUtils.equals(remotePlugin.getString("running"), "false") || (remotePlugin.containsKey("sync") && !remotePlugin.getBoolean("sync"))) {
continue;
}
String remotePluginID = remotePlugin.getString(ID);

26
designer-base/src/main/java/com/fr/env/CheckServiceDialog.java vendored

@ -36,6 +36,8 @@ import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.util.List;
import javax.swing.BorderFactory;
@ -172,7 +174,7 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
ignoreButton.addActionListener(this);
syncButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Sync_To_Local"));
syncButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Sync_To_Local_Tip"));
syncButton.addMouseListener(syncButtonClickListener);
syncButton.addActionListener(syncButtonActionListener);
if(jarConsistency && differentPlugins.isEmpty()){
syncButton.setEnabled(false);
}
@ -186,8 +188,10 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
buttonPanel.add(progressBar, BorderLayout.CENTER);
buttonPanel.add(syncButton, BorderLayout.EAST);
} else {
UILabel adviceLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_Suggestion"));
centerPanel.add(adviceLabel, BorderLayout.SOUTH);
if (!(jarConsistency && differentPlugins.isEmpty())) {
UILabel adviceLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_Suggestion"));
centerPanel.add(adviceLabel, BorderLayout.SOUTH);
}
UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Button_Confirm"));
okButton.addActionListener(this);
buttonPanel.add(okButton, BorderLayout.EAST);
@ -198,6 +202,12 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
this.add(centerPanel, BorderLayout.CENTER);
this.add(buttonPanel, BorderLayout.SOUTH);
this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 750 : 600, 500));
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
close();
}
});
GUICoreUtils.centerWindow(this);
}
@ -308,10 +318,10 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
}
};
private MouseListener syncButtonClickListener = new MouseAdapter() {
private ActionListener syncButtonActionListener = new ActionListener() {
@Override
public void mouseClicked(MouseEvent e) {
sync();
public void actionPerformed(ActionEvent e) {
sync();
}
};
@ -352,6 +362,9 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
helper.restartForUpdate(frame);
}
}.execute();
} else {
ignoreButton.setEnabled(true);
syncButton.setEnabled(true);
}
} else {
//到这边说明主jar是一致的,就只尝试同步插件
@ -389,7 +402,6 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
}
}
private boolean deletePreviousPropertyFile() {
File moveFile = new File(RestartHelper.MOVE_FILE);
File delFile = new File(RestartHelper.RECORD_FILE);

8
designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java vendored

@ -21,6 +21,8 @@ import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Locale;
import javax.swing.BorderFactory;
import javax.swing.Icon;
@ -96,6 +98,12 @@ public class SyncFailedPluginsDialog extends JDialog {
this.setResizable(false);
this.add(body, BorderLayout.CENTER);
this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 400 : 380, 225));
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
hideDialog();
}
});
GUICoreUtils.centerWindow(this);
}

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_e.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_n.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_ne.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_nw.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_s.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_se.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_sw.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_w.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

12
designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java

@ -43,6 +43,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
public ChartComponent() {
super();
setOpaque(true);
addMouseListener(this);
addMouseMotionListener(this);
}
@ -148,11 +149,12 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
chartCollection4Design.setPredefinedStyleName(getGlobalPredefinedStyleName(), false);
Graphics2D g2d = (Graphics2D) g;
Paint oldPaint = g2d.getPaint();
g2d.setPaint(Color.WHITE);
g2d.fillRect(0, 0, this.getBounds().width, this.getBounds().height);
g2d.setPaint(oldPaint);
if (this.isOpaque()) {
Paint oldPaint = g2d.getPaint();
g2d.setPaint(Color.WHITE);
g2d.fillRect(0, 0, this.getBounds().width, this.getBounds().height);
g2d.setPaint(oldPaint);
}
g2d.translate(ChartConstants.PREGAP4BOUNDS/2, ChartConstants.PREGAP4BOUNDS/2);

7
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java

@ -9,6 +9,7 @@ import com.fr.design.designer.properties.BoundsGroupModel;
import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
@ -295,6 +296,12 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
*/
@Override
public void fix(XCreator creator) {
Widget widget = creator.toData();
Rectangle bounds = creator.getBounds();
if (widget != null && widget.isAspectRatioLocked() && (bounds.width == 0 || bounds.height == 0)) {
widget.setAspectRatioLocked(false);
widget.setAspectRatioBackup(-1.0);
}
WAbsoluteLayout wabs = (WAbsoluteLayout)container.toData();
fix(creator,creator.getX(),creator.getY());
wabs.setBounds(creator.toData(),creator.getBounds());

2
designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java

@ -93,7 +93,7 @@ public class DesignerEditor<T extends JComponent> implements PropertyChangeListe
comp.setSize(new Dimension(width, height));
LayoutUtils.layoutContainer(comp);
comp.setBounds(comp.getX() + x, comp.getY() + y, width, height);
comp.setBounds(comp.getX() + x - 1, comp.getY() + y - 1, width, height);
Graphics clipg = g.create(x, y, width, height);
this.comp.paint(clipg);
}

120
designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java

@ -35,6 +35,9 @@ import java.awt.geom.RoundRectangle2D;
public class XBorderStyleWidgetCreator extends XWidgetCreator{
protected static final Dimension BORDER_PREFERRED_SIZE = new Dimension(250, 150);
protected Background background4Painting; // 设计器预览界面中绘制组件背景图
protected double backgroundOpacity4Painting; // 设计器预览界面中绘制组件背景图
protected Background borderImage4Painting; // 设计器预览界面中绘制边框图片
protected double borderImageOpacity4Painting;
public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) {
super(widget, initSize);
@ -49,9 +52,26 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
return this.background4Painting;
}
public void setBackground4Painting(Background background4Painting) {
this.background4Painting = background4Painting;
this.repaint();
public double getBackgroundOpacity4Painting() {
return backgroundOpacity4Painting;
}
public void setBackground4Painting(Background background, double opacity) {
this.background4Painting = background;
this.backgroundOpacity4Painting = opacity;
}
public Background getBorderImage4Painting() {
return borderImage4Painting;
}
public double getBorderImageOpacity4Painting() {
return borderImageOpacity4Painting;
}
public void setBorderImage4Painting(Background borderImage, double opacity) {
this.borderImage4Painting = borderImage;
this.borderImageOpacity4Painting = opacity;
}
/**
@ -102,8 +122,13 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
}
this.setBorder(border);
this.setBackground4Painting(style != null ? style.getBackground() : null);
if (style != null) {
this.setBorderImage4Painting(style.getBorderImage(), style.getBorderImageOpacity());
this.setBackground4Painting(style.getBackground(), style.getAlpha());
} else {
this.setBorderImage4Painting(null, 0.0);
this.setBackground4Painting(null, 0.0);
}
}
private void clearTitleWidget() {
@ -183,25 +208,57 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
XCreator titleCreator = titleParent.getTitleCreator();
XCreator bodyXCreator = titleParent.getBodyCreator();
Border border = bodyXCreator.getBorder();
reshuffleBorderPaintingEffectIfTitleExists(titleParent, titleCreator, bodyXCreator);
reshuffleBackgroundPaintingEffectIfTitleExists(titleParent, titleCreator, bodyXCreator);
} else {
titleParent.setBorder(null);
titleParent.setBorderImage4Painting(null, 0.0);
titleParent.setBackground4Painting(null, 0.0);
}
}
}
titleParent.setBorder(border); // 容器绘制完整边框
bodyXCreator.setBorder(BorderFactory.createEmptyBorder()); // body不绘制边框
titleCreator.setBorder(BorderFactory.createEmptyBorder()); // title绘制底部边框
if (border instanceof LineBorder) {
Color color = ((LineBorder) border).getLineColor();
int thickness = ((LineBorder) border).getThickness();
titleCreator.setBorder(new BottomLineBorder(color, thickness));
}
private void reshuffleBorderPaintingEffectIfTitleExists(XWTitleLayout parentCreator, XCreator titleCreator, XCreator bodyCreator) {
Border border = bodyCreator.getBorder();
if (bodyXCreator instanceof XBorderStyleWidgetCreator) {
XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyXCreator;
Background background4Painting = styledBodyXCreator.getBackground4Painting();
parentCreator.setBorder(border); // 容器绘制完整边框
bodyCreator.setBorder(BorderFactory.createEmptyBorder()); // body不绘制边框
titleCreator.setBorder(BorderFactory.createEmptyBorder()); // title绘制底部边框
if (border instanceof LineBorder) {
Color color = ((LineBorder) border).getLineColor();
int thickness = ((LineBorder) border).getThickness();
titleCreator.setBorder(new BottomLineBorder(color, thickness));
}
styledBodyXCreator.setBackground4Painting(null); // body不绘制背景
titleParent.setBackground4Painting(background4Painting); // 容器绘制完整背景
}
}
if (bodyCreator instanceof XBorderStyleWidgetCreator) {
XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyCreator;
Background borderImage= styledBodyXCreator.getBorderImage4Painting();
double opacity = styledBodyXCreator.getBorderImageOpacity4Painting();
styledBodyXCreator.setBorderImage4Painting(null, 0.0); // body不绘制图片边框
parentCreator.setBorderImage4Painting(borderImage, opacity); // 容器绘制完整图片边框
}
}
private void reshuffleBackgroundPaintingEffectIfTitleExists(XWTitleLayout parentCreator, XCreator titleCreator, XCreator bodyCreator) {
if (titleCreator instanceof XLabel) {
XLabel labelCreator = (XLabel) titleCreator;
Label titleLabel = labelCreator.toData();
Background background = titleLabel.getBackground();
double opacity = titleLabel.getBackgroundOpacity();
labelCreator.setEnabledBackgroundPainting(false); // 标题不绘制背景
parentCreator.setTitleBackground4Painting(background, opacity); // 容器绘制完整背景
}
if (bodyCreator instanceof XBorderStyleWidgetCreator) {
XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyCreator;
Background background = styledBodyXCreator.getBackground4Painting();
double opacity = styledBodyXCreator.getBackgroundOpacity4Painting();
styledBodyXCreator.setBackground4Painting(null, 0.0); // body不绘制背景
parentCreator.setBodyBackground4Painting(background, opacity); // 容器绘制完整背景
}
}
@ -225,7 +282,23 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
public void paintBackground(Graphics2D g2d) {
Background background4Painting = getBackground4Painting();
if (background4Painting != null) {
background4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) backgroundOpacity4Painting));
Shape shape = new Rectangle2D.Double(0, 0, getWidth(), getHeight());
background4Painting.paint(g2d, shape);
g2d.setComposite(oldComposite);
}
}
public void paintBorderImage(Graphics2D g2d) {
Background borderImage4Painting = getBorderImage4Painting();
if (borderImage4Painting != null) {
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) borderImageOpacity4Painting));
borderImage4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
g2d.setComposite(oldComposite);
}
}
@ -238,6 +311,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
public void paint(Graphics g) {
this.clipByRoundedBorder((Graphics2D) g);
this.paintBackground((Graphics2D) g);
this.paintBorderImage((Graphics2D) g);
this.paintForeground((Graphics2D) g);
}
@ -288,7 +362,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(getLineColor());
g2d.setStroke(new BasicStroke(getThickness()));
g2d.setStroke(new BasicStroke(getThickness() * 2));
g2d.drawLine(0, height, width, height);
g2d.setStroke(oldStroke);

3
designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java

@ -231,7 +231,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
public void paintForeground(Graphics2D g) {
Dimension size = getSize();
PaddingMargin margin = toData().getMargin();
designerEditor.paintEditor(g, size, margin);
if (coverPanel != null) {
int horizonMargin = margin != null ? margin.getLeft() + margin.getRight() : 0;
int verticalMargin = margin != null ? margin.getTop() + margin.getBottom() : 0;
@ -289,6 +291,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
final MiddleChartComponent chartComponent = DesignModuleFactory.getChartComponent(((BaseChartEditor) data).getChartCollection());
if (chartComponent != null) {
JComponent jChart = chartComponent;
chartComponent.setOpaque(false);
jChart.setBorder(BorderFactory.createLineBorder(Color.lightGray));
designerEditor = new DesignerEditor<JComponent>(jChart);
chartComponent.addStopEditingListener(designerEditor);

38
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -23,6 +23,7 @@ import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.NoSupportAuthorityEdit;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.plugin.DesignerPluginContext;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout;
@ -33,6 +34,7 @@ import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.border.Border;
import java.awt.BorderLayout;
import java.awt.Color;
@ -774,12 +776,30 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
if (popup == null) {
popup = new SelectedPopupDialog(this, designer);
}
int extraX = (int) ((bounds.x + bounds.width + SelectedPopupDialog.OFFSET_X) * designer.getScale());
int extraY = (int) (bounds.y * designer.getScale());
popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY);
popup.updatePane(designer);
popup.setVisible(selected && accept && popup.hasVisibleButtons());
popup.setRelativeBounds(bounds);
int creatorRightX = (int) ((bounds.x + bounds.width + SelectedPopupDialog.OFFSET_X) * designer.getScale());
int creatorRightY = (int) (bounds.y * designer.getScale());
int formDesignerWidth = designer.getWidth();
int formDesignerHeight = designer.getHeight();
// 不超过可绘制区域
int extraX = Math.min(creatorRightX, formDesignerWidth);
int extraY = creatorRightY < 0 ? 0 : Math.min(creatorRightY, formDesignerHeight);
// 放到事件尾部执行
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY);
popup.updatePane(designer);
popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible() && !isShowPluginDialog());
popup.setRelativeBounds(bounds);
}
});
}
private boolean isShowPluginDialog() {
if (DesignerPluginContext.getPluginDialog() == null) {
return false;
}
return DesignerPluginContext.getPluginDialog().isVisible();
}
/**
@ -836,4 +856,10 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
}
}
public void processPopup(boolean canVisible) {
if (popup != null) {
popup.setCanVisible(canVisible);
}
}
}

8
designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java

@ -41,7 +41,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
static {
try {
DEFAULT_BACKGROUND = BaseUtils.readImageWithCache("com/fr/base/images/report/elementcase.png");
DEFAULT_BACKGROUND = BaseUtils.readImageWithCache("com/fr/base/images/report/elementcase_translucent.png");
} catch (Throwable e) {
//IBM jdk 1.5.0_22 并发下读取图片有时会异常(EOFException), 这个图片反正只有设计器用到, 捕获住
DEFAULT_BACKGROUND = CoreGraphHelper.createBufferedImage(0, 0);
@ -183,7 +183,8 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
if (editor == null) {
setBorder(DEFALUTBORDER);
editor = new JPanel();
editor.setBackground(null);
editor.setOpaque(false);
editor.setBackground(new Color(0, 0, 0, 0));
editor.setLayout(null);
imageLable = initImageBackground();
@ -218,7 +219,8 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
private void setLabelBackground(Image image, UILabel imageLable) {
ImageIcon icon = new ImageIcon(image);
imageLable.setIcon(icon);
imageLable.setOpaque(true);
imageLable.setOpaque(false);
imageLable.setBackground(new Color(0, 0, 0, 0));
imageLable.setLayout(null);
imageLable.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight());
}

14
designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java

@ -35,11 +35,16 @@ import java.beans.IntrospectionException;
public class XLabel extends XWidgetCreator {
private int cornerSize = 15;
private boolean enabledBackgroundPainting = true;
public XLabel(Label widget, Dimension initSize) {
super(widget, initSize);
}
public void setEnabledBackgroundPainting(boolean enable) {
this.enabledBackgroundPainting = enable;
}
/**
* 生成creator对应的控件widget
*
@ -91,8 +96,13 @@ public class XLabel extends XWidgetCreator {
Label label = (Label) data;
Dimension size = this.getSize();
//先画背景,再画标题
if (toData().getBackground() != null) {
toData().getBackground().paint(g, new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight()));
Background background = label.getBackground();
if (background != null && enabledBackgroundPainting) {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, label.getBackgroundOpacity()));
background.paint(g, new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight()));
g2d.setComposite(oldComposite);
}
if (label.getWidgetValue() != null) {
Graphics2D g2d = (Graphics2D) g.create();

23
designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -386,7 +386,18 @@ public class XWAbsoluteLayout extends XLayoutContainer {
if (!creator.acceptType(XWFitLayout.class)) {
creator.setDirections(Direction.ALL);
}
wabs.addWidget(new BoundsWidget(creator.toData(), creator.getBounds()));
Widget wgt = creator.toData();
if (wgt != null && wgt.isAspectRatioLocked() && wgt.getAspectRatioBackup() <= 0) {
// 将比例锁定的组件重新移会绝对布局内时(如body修改绝对布局),尺寸比例可能失效,需要重新计算
Rectangle bounds = creator.getBounds();
if (bounds.width > 0 && bounds.height > 0) {
wgt.setAspectRatioBackup(1.0 * bounds.width / bounds.height);
} else {
wgt.setAspectRatioLocked(false);
wgt.setAspectRatioBackup(-1);
}
}
wabs.addWidget(new BoundsWidget(wgt, creator.getBounds()));
}
/**
@ -402,6 +413,11 @@ public class XWAbsoluteLayout extends XLayoutContainer {
WAbsoluteLayout wlayout = this.toData();
XWidgetCreator xwc = ((XWidgetCreator) e.getChild());
Widget wgt = xwc.toData();
// 将比例锁定的组件重新移出绝对布局时(如body修改为自适应布局),锁定的尺寸比例失效
if (wgt != null) {
wgt.setAspectRatioBackup(-1.0);
}
BoundsWidget bw = new BoundsWidget(wgt, xwc.getBounds());
wlayout.removeWidget(bw);
}
@ -447,10 +463,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
super.paint(g);
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (isMouseEnter && !this.editable) {
CoverReportPane.paintEditButton(g, this);
if (isShared()) {
CoverReportPane.paintShareButton(g, this);
}
CoverReportPane.paintCover(g, this);
}
}

61
designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java

@ -12,10 +12,12 @@ import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetTitle;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.Background;
import com.fr.general.ComparatorUtils;
import java.awt.*;
import java.awt.event.ContainerEvent;
import java.awt.geom.Rectangle2D;
/**
* 一些控件 如图表报表块有标题设置且标题的高度字体等不变
@ -31,6 +33,11 @@ public class XWTitleLayout extends DedicateLayoutContainer {
private static final int INDEX = 0;
protected Background titleBackground4Painting; // 设计器预览界面中绘制title背景图
protected double titleBackgroundOpacity4Painting;
protected Background bodyBackground4Painting; // 设计器预览界面中绘制body背景图
protected double bodyBackgroundOpacity4Painting;
public XWTitleLayout() {
super(new WTitleLayout("titlePane"), new Dimension());
}
@ -45,6 +52,23 @@ public class XWTitleLayout extends DedicateLayoutContainer {
super(widget, initSize);
}
public void setTitleBackground4Painting(Background background, double opacity) {
this.titleBackground4Painting = background;
this.titleBackgroundOpacity4Painting = opacity;
}
public void setBodyBackground4Painting(Background background, double opacity) {
this.bodyBackground4Painting = background;
this.bodyBackgroundOpacity4Painting = opacity;
}
@Override
protected void initBorderAndBackgroundStyle() {
setBorder(null);
setBorderImage4Painting(null, 0.0);
setBackground4Painting(null, 0.0);
}
@Override
protected void initXCreatorProperties() {
super.initXCreatorProperties();
@ -150,6 +174,43 @@ public class XWTitleLayout extends DedicateLayoutContainer {
}
@Override
public void paintBackground(Graphics2D g2d) {
if (getComponentCount() > 1) {
paintTitleBackground(g2d);
paintBodyBackground(g2d);
}
}
private void paintTitleBackground(Graphics2D g2d) {
if (titleBackground4Painting != null) {
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) this.titleBackgroundOpacity4Painting));
XCreator titleCreator = getTitleCreator();
int titleHeight = titleCreator != null ? titleCreator.getHeight() : 0;
Shape shape = new Rectangle2D.Double(0, 0, getWidth(), titleHeight);
titleBackground4Painting.paint(g2d, shape);
g2d.setComposite(oldComposite);
}
}
private void paintBodyBackground(Graphics2D g2d) {
if (bodyBackground4Painting != null) {
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) this.bodyBackgroundOpacity4Painting));
XCreator titleCreator = getTitleCreator();
int titleHeight = titleCreator != null ? titleCreator.getHeight() : 0;
// 兼容性考虑,组件样式背景不作用在标题范围内,只作用在控件整体,但同时不能遮挡作用于整体的边框图片
// 所以考虑样式背景与边框图片都由XWTitleLayout绘制,但样式背景要向下偏移标题栏的高度
Shape shape = new Rectangle2D.Double(0, titleHeight, getWidth(), getHeight() - titleHeight);
bodyBackground4Painting.paint(g2d, shape);
g2d.setComposite(oldComposite);
}
}
/**
* 将WLayout转换为XLayoutContainer

26
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java

@ -62,6 +62,8 @@ public class XWCardMainBorderLayout extends XWBorderLayout {
private final int CARDMAINLAYOUT_CHILD_COUNT = 1;
private boolean showOuterShadowBorder;
/**
* 构造函数
*/
@ -342,24 +344,24 @@ public class XWCardMainBorderLayout extends XWBorderLayout {
super.paint(g);
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (isMouseEnter && !editable) {
CoverReportPane.paintEditButton(g, this);
if (isShared()) {
CoverReportPane.paintShareButton(g, this);
}
CoverReportPane.paintCover(g, this);
}
}
@Override
public void paintBorder(Graphics g, Rectangle bounds){
if (isDragInAble()) {
if (!isMouseEnter) {
super.paintBorder(g, bounds);
}
}
public void paintShadowBorder(Graphics g, Rectangle bounds) {
if (isDragInAble() || showOuterShadowBorder) {
Color oldColor = g.getColor();
g.setColor(OUTER_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(bounds.x - BORDER_WIDTH, bounds.y - BORDER_WIDTH, bounds.width + BORDER_WIDTH + 3, bounds.height + BORDER_WIDTH + 3), Constants.LINE_LARGE);
g.setColor(oldColor);
}
if (!isMouseEnter) {
super.paintBorder(g, bounds);
}
}
/**
@ -413,7 +415,10 @@ public class XWCardMainBorderLayout extends XWBorderLayout {
*/
@Override
public void firePropertyChange(){
return;
XWCardLayout cardLayout = this.getCardPart();
if (cardLayout != null && cardLayout.toData() != null) {
cardLayout.initStyle();
}
}
@ -464,4 +469,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout {
return LARGEPREFERREDSIZE;
}
public void setShowOuterShadowBorder(boolean showOuterShadowBorder) {
this.showOuterShadowBorder = showOuterShadowBorder;
}
}

17
designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java

@ -4,13 +4,16 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.CoverReportPane;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.Widget;
import com.fr.general.IOUtils;
import com.fr.stable.ArrayUtils;
@ -92,7 +95,17 @@ public class PopupControlPanel extends JPanel {
JToggleButton toggleBtn = (JToggleButton) e.getSource();
String toolTipText = toggleBtn.isSelected() ? Toolkit.i18nText("Fine-Design_Form_Lock_Widget_Ratio") : Toolkit.i18nText("Fine-Design_Form_UnLock_Widget_Ratio");
toggleBtn.setToolTipText(toolTipText);
creator.toData().setAspectRatioLocked(toggleBtn.isSelected());
Widget widget = creator.toData();
if (widget != null) {
Rectangle bounds = new Rectangle(creator.getBounds());
if (toggleBtn.isSelected() && bounds.width > 0 && bounds.height > 0) {
widget.setAspectRatioLocked(true);
widget.setAspectRatioBackup(1.0 * bounds.width / bounds.height);
} else {
widget.setAspectRatioLocked(false);
widget.setAspectRatioBackup(-1.0);
}
}
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_RESIZED);
}
});
@ -193,7 +206,7 @@ public class PopupControlPanel extends JPanel {
}
public void updatePane(FormDesigner designer) {
setButtonVisible(editButton, creator.acceptType(XWTitleLayout.class));
setButtonVisible(editButton, creator.acceptType(XWTitleLayout.class, XWCardMainBorderLayout.class) || creator.getClass().equals(XWAbsoluteLayout.class));
setButtonVisible(settingButton, creator.isShared());
setButtonVisible(toggleButton, AdapterBus.searchLayoutAdapter(designer, creator) instanceof FRAbsoluteLayoutAdapter);
toggleButton.setSelected(creator.toData().isAspectRatioLocked());

14
designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java

@ -3,8 +3,11 @@ package com.fr.design.designer.ui;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner;
import com.fr.stable.os.OperatingSystem;
import java.awt.Rectangle;
import javax.swing.JDialog;
import javax.swing.JFrame;
/**
* @author hades
@ -20,8 +23,10 @@ public class SelectedPopupDialog extends JDialog {
private final PopupControlPanel controlPanel;
private boolean canVisible = true;
public SelectedPopupDialog(XCreator creator, FormDesigner designer) {
super(DesignerContext.getDesignerFrame());
super(OperatingSystem.isMacos() ? new JFrame() : DesignerContext.getDesignerFrame());
this.setUndecorated(true);
this.setModal(false);
this.setFocusableWindowState(false);
@ -43,4 +48,11 @@ public class SelectedPopupDialog extends JDialog {
this.controlPanel.setRelativeBounds(rectangle);
}
public boolean isCanVisible() {
return canVisible;
}
public void setCanVisible(boolean canVisible) {
this.canVisible = canVisible;
}
}

386
designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java

@ -20,13 +20,13 @@ import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UIIntNumberField;
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.design.mainframe.backgroundpane.ImagePreviewPane;
import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.env.utils.DesignerInteractionHistory;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.general.Background;
@ -38,15 +38,28 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
@ -73,7 +86,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private UIObserverListener uiObserverListener;
private BorderLineAndImageComboBox borderLineCombo;
private UIColorButton borderColorPane;
private NewColorSelectBox borderColorPane;
private ImagePreviewPane imagePreviewPane;
private UIButton chooseImageButton;
private UIButton tweakNinePointHelpButton;
@ -85,17 +98,14 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private int[] ninePoint = new int[] {-1, -1, -1, -1};
public BorderLineAndImagePane() {
this.initComponents();
public BorderLineAndImagePane(boolean supportBorderImage) {
this.initComponents(supportBorderImage);
this.initLayout();
}
private void initComponents() {
borderLineCombo = new BorderLineAndImageComboBox();
borderColorPane = new UIColorButton(null) {{
setUI(createButtonUI(this));
set4ToolbarButton();
}};
private void initComponents(boolean supportBorderImage) {
borderLineCombo = new BorderLineAndImageComboBox(supportBorderImage);
borderColorPane = new NewColorSelectBox(145);
imagePreviewPane = new ImagePreviewPane() {{
setImageStyle(Style.DEFAULT_STYLE);
}};
@ -216,7 +226,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
getComponent(2).setVisible(borderLineCombo.isSelectedBorderImage());
if (!borderLineCombo.isSelectedBorderLine()) {
borderColorPane.setColor(Color.BLACK);
borderColorPane.setSelectObject(Color.BLACK);
}
if (!borderLineCombo.isSelectedBorderImage()) {
imagePreviewPane.setImageWithSuffix(null);
@ -282,7 +292,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
Color borderColor = style.getColor();
this.borderLineCombo.setSelectedLineStyle(borderLine);
this.borderColorPane.setColor(borderColor);
this.borderColorPane.setSelectObject(borderColor);
Background borderImage = style.getBorderImage();
if (borderImage instanceof ImageBackground) {
@ -320,13 +330,13 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
}
this.borderLineCombo.setSelectedLineStyle(style.getBorder());
this.borderColorPane.setColor(style.getColor());
this.borderColorPane.setSelectObject(style.getColor());
}
public void updateBean(LayoutBorderStyle style) {
style.setBorder(this.borderLineCombo.getSelectedLineStyle());
style.setColor(this.borderColorPane.getColor());
style.setColor(this.borderColorPane.getSelectObject());
style.setBorderImage(null);
if (this.borderLineCombo.isSelectedBorderImage()) {
@ -376,16 +386,25 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
protected static class BorderLineAndImageComboBox extends LineComboBox {
public static final int LINE_PICTURE = -1;
public final static int[] BORDER_LINE_STYLE_ARRAY = new int[] {
public final static int[] BORDER_LINE_AND_IMAGE_STYLE_ARRAY = new int[] {
Constants.LINE_NONE,
LINE_PICTURE,
Constants.LINE_THIN, //1px
Constants.LINE_MEDIUM, //2px
Constants.LINE_THICK, //3px
};
public final static int[] BORDER_LINE_STYLE_ARRAY = new int[] {
Constants.LINE_NONE,
Constants.LINE_THIN, //1px
Constants.LINE_MEDIUM, //2px
Constants.LINE_THICK, //3px
};
private boolean supportBorderImage = false;
public BorderLineAndImageComboBox() {
super(BORDER_LINE_STYLE_ARRAY);
public BorderLineAndImageComboBox(boolean supportBorderImage) {
super(supportBorderImage ? BORDER_LINE_AND_IMAGE_STYLE_ARRAY : BORDER_LINE_STYLE_ARRAY);
this.supportBorderImage = supportBorderImage;
}
@Override
@ -397,15 +416,27 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
}
public boolean isSelectedBorderLine() {
return getSelectedIndex() > 1;
Object object = getSelectedItem();
if (object != null) {
int value = (int) object;
return value > 0;
}
return false;
}
public boolean isSelectedBorderImage() {
return getSelectedIndex() == 1;
Object object = getSelectedItem();
if (object != null) {
int value = (int) object;
return value == LINE_PICTURE;
}
return false;
}
public void selectBorderImage() {
this.setSelectedIndex(1);
if (supportBorderImage) {
this.setSelectedIndex(1);
}
}
}
@ -434,13 +465,36 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private class NinePointLinePreviewPane extends JPanel implements MouseMotionListener, MouseListener {
public final Color BACKGROUND_PANE_COLOR = Color.WHITE;
public final Color BACKGROUND_IMG_COLOR = Color.lightGray;
public final Color DIVIDER_BACKGROUND_COLOR = Color.WHITE;
public final Color DIVIDER_FOREGROUND_COLOR = Color.BLACK;
public final Color HINT_BACKGROUND_COLOR = new Color(255, 255, 255, 100);
public final Color HINT_FOREGROUND_COLOR = Color.RED;
public final Color HINT_LINE_BACKGROUND_COLOR = Color.WHITE;
public final Color HINT_LINE_FOREGROUND_COLOR = Color.RED;
public final Color DIVIDER_BACKGROUND_COLOR = new Color(235, 29, 31);
public final Color DIVIDER_FOREGROUND_COLOR = Color.WHITE;
public final Color HINT_BACKGROUND_COLOR = new Color(0, 215, 215);
public final Color HINT_FOREGROUND_COLOR = Color.WHITE;
public final int HINT_GAP = 5;
public final int PADDING = 20;
public final Cursor E_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_e.png"),
new Point(8, 8), "E_DRAG_CURSOR");
public final Cursor S_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_s.png"),
new Point(8, 8), "S_DRAG_CURSOR");
public final Cursor W_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_w.png"),
new Point(8, 8), "W_DRAG_CURSOR");
public final Cursor N_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_n.png"),
new Point(8, 8), "N_DRAG_CURSOR");
public final Cursor NE_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_ne.png"),
new Point(8, 8), "NE_DRAG_CURSOR");
public final Cursor NW_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_nw.png"),
new Point(8, 8), "NW_DRAG_CURSOR");
public final Cursor SE_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_se.png"),
new Point(8, 8), "SE_DRAG_CURSOR");
public final Cursor SW_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_sw.png"),
new Point(8, 8), "SW_DRAG_CURSOR");
private int ninePointLeft = -1;
private int ninePointTop = -1;
@ -455,54 +509,17 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private int scaleImgHeight;
private int scaleImgX;
private int scaleImgY;
private double scale = 1.0;
private double imageScale = 1.0;
private final UIIntNumberField topField = createNumberField();
private final UIIntNumberField bottomField = createNumberField();
private final UIIntNumberField leftField = createNumberField();
private final UIIntNumberField rightField = createNumberField();
private boolean draggingLeftDivider = false;
private boolean draggingRightDivider = false;
private boolean draggingTopDivider = false;
private boolean draggingBottomDivider = false;
public NinePointLinePreviewPane() {
this.setLayout(null);
this.addMouseMotionListener(this);
this.addMouseListener(this);
this.setFocusable(true);
this.add(topField);
this.add(bottomField);
this.add(leftField);
this.add(rightField);
topField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
int value = (int) topField.getValue();
onNinePointTopChanged(value);
}
});
bottomField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
int value = (int) bottomField.getValue();
onNinePointBottomChanged(value);
}
});
leftField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
int value = (int) leftField.getValue();
onNinePointLeftChanged(value);
}
});
rightField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
int value = (int) rightField.getValue();
onNinePointRightChanged(value);
}
});
}
@Override
@ -528,68 +545,115 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
scaleImgHeight = (int) (1.0F * scaleImgWidth * imgHeight / imgWidth);
scaleImgX = autoFixAreaX;
scaleImgY = (autoFixAreaHeight - scaleImgHeight) / 2 + autoFixAreaY; // 垂直居中
scale = 1.0 * scaleImgWidth / imgWidth;
imageScale = 1.0 * scaleImgWidth / imgWidth;
} else {
scaleImgHeight = autoFixAreaHeight;
scaleImgWidth = (int) (1.0F * scaleImgHeight * imgWidth / imgHeight);
scaleImgX = (autoFixAreaWidth - scaleImgWidth) / 2 + autoFixAreaX; // 水平居中
scaleImgY = autoFixAreaY;
scale = 1.0 * scaleImgHeight / imgHeight;
imageScale = 1.0 * scaleImgHeight / imgHeight;
}
g2d.setColor(BACKGROUND_IMG_COLOR);
g2d.fillRect(scaleImgX, scaleImgY, scaleImgWidth, scaleImgHeight);
g2d.drawImage(image, scaleImgX, scaleImgY, scaleImgWidth, scaleImgHeight, null);
int scaleLeft = (int) (ninePointLeft * scale);
int scaleTop = (int) (ninePointTop * scale);
int scaleRight = (int) (ninePointRight * scale);
int scaleBottom = (int) (ninePointBottom * scale);
int scaleLeft = (int) (ninePointLeft * imageScale);
int scaleTop = (int) (ninePointTop * imageScale);
int scaleRight = (int) (ninePointRight * imageScale);
int scaleBottom = (int) (ninePointBottom * imageScale);
double topYInPane = scaleImgY + scaleTop;
double bottomYInPane = scaleImgY + scaleImgHeight - scaleBottom;
double leftXInPane = scaleImgX + scaleLeft;
double rightXInPane = scaleImgX + scaleImgWidth - scaleRight;
// 绘制分割线
// 顶部
drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, scaleImgX, topYInPane, scaleImgX + scaleImgWidth, topYInPane);
// 底部
drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, scaleImgX, bottomYInPane, scaleImgX + scaleImgWidth, bottomYInPane);
// 左侧
drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, leftXInPane, scaleImgY, leftXInPane, scaleImgY + scaleImgHeight);
// 右侧
drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, rightXInPane, scaleImgY, rightXInPane, scaleImgY + scaleImgHeight);
// 绘制分割线位置提示
// 顶部
drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, (leftXInPane + rightXInPane) / 2.0F, scaleImgY, (leftXInPane + rightXInPane) / 2.0F, topYInPane);
drawHint(g2d, Integer.toString(ninePointTop), (leftXInPane + rightXInPane) / 2.0F, (scaleImgY + topYInPane) / 2.0, topField);
// 底部
drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, (leftXInPane + rightXInPane) / 2.0F, bottomYInPane, (leftXInPane + rightXInPane) / 2.0F, scaleImgY + scaleImgHeight);
drawHint(g2d, Integer.toString(ninePointBottom), (leftXInPane + rightXInPane) / 2.0F, (bottomYInPane + scaleImgY + scaleImgHeight) / 2.0, bottomField);
// 左侧
drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, scaleImgX, (topYInPane + bottomYInPane) / 2.0, leftXInPane, (topYInPane + bottomYInPane) / 2.0);
drawHint(g2d, Integer.toString(ninePointLeft), (scaleImgX + leftXInPane) / 2.0, (topYInPane + bottomYInPane) / 2.0, leftField);
// 右侧
drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, rightXInPane, (topYInPane + bottomYInPane) / 2.0, scaleImgX + scaleImgWidth, (topYInPane + bottomYInPane) / 2.0);
drawHint(g2d, Integer.toString(ninePointRight), (rightXInPane + scaleImgX + scaleImgWidth) / 2.0, (topYInPane + bottomYInPane) / 2.0, rightField);
}
private void drawHint(Graphics2D g2d, String hint, double centerX, double centerY, UIIntNumberField hintField) {
// 顶部分割线
drawDivider(g2d, scaleImgX, topYInPane, scaleImgX + scaleImgWidth, topYInPane, draggingTopDivider);
if (draggingTopDivider) {
// 顶部提示
drawHint(g2d, ninePointTop + "px", leftXInPane, scaleImgY, scaleImgWidth - scaleLeft - scaleRight, scaleTop, false);
}
// 底部分割线
drawDivider(g2d, scaleImgX, bottomYInPane, scaleImgX + scaleImgWidth, bottomYInPane, draggingBottomDivider);
if (draggingBottomDivider) {
// 底部提示
drawHint(g2d, ninePointBottom + "px", leftXInPane, bottomYInPane, scaleImgWidth - scaleLeft - scaleRight, scaleBottom, false);
}
// 左侧分割线
drawDivider(g2d, leftXInPane, scaleImgY, leftXInPane, scaleImgY + scaleImgHeight, draggingLeftDivider);
if (draggingLeftDivider) {
// 左侧提示
drawHint(g2d, ninePointLeft + "px", scaleImgX, topYInPane, scaleLeft, scaleImgHeight - scaleTop - scaleBottom, true);
}
// 右侧分割线
drawDivider(g2d, rightXInPane, scaleImgY, rightXInPane, scaleImgY + scaleImgHeight, draggingRightDivider);
if (draggingRightDivider) {
// 右侧提示
drawHint(g2d, ninePointRight + "px", rightXInPane, topYInPane, scaleRight, scaleImgHeight - scaleTop - scaleBottom, true);
}
}
private void drawHint(Graphics2D g2d, String hint, double x, double y, double width, double height, boolean horizontal) {
FontMetrics metrics = GraphDrawHelper.getFontMetrics(g2d.getFont());
double height = metrics.getAscent() + metrics.getDescent();
double width = Math.max(metrics.stringWidth(" " + hint + " "), metrics.stringWidth(" 123 "));
double hintTextHeight = Math.max(metrics.getAscent() + metrics.getDescent(), 16);
double hintTextWidth = Math.max(metrics.stringWidth(hint), metrics.stringWidth("123"));
double hintFrameRadius = hintTextHeight / 2;
double hintFrameHeight = hintTextHeight;
double hintFrameWidth = hintTextWidth + 2 * hintFrameRadius;
double centerX = x + width / 2;
double centerY = y + height / 2;
double indent = 1.0;
double shortLine = 4.0;
if (horizontal) {
if (width > hintFrameWidth) {
g2d.setColor(HINT_BACKGROUND_COLOR);
GraphDrawHelper.draw(g2d, new Line2D.Double(x + indent, centerY, x + width - indent, centerY), Constants.LINE_THIN, 1.0F);
GraphDrawHelper.draw(g2d, new Line2D.Double(x + indent, centerY - shortLine, x + indent, centerY + shortLine), Constants.LINE_THIN, 1.0F);
GraphDrawHelper.draw(g2d, new Line2D.Double(x + width - indent, centerY - shortLine, x + width - indent, centerY + shortLine), Constants.LINE_THIN, 1.0F);
}
double hintFrameX = centerX - hintFrameWidth / 2;
double hintFrameY = centerY + HINT_GAP;
g2d.setColor(HINT_BACKGROUND_COLOR);
GraphDrawHelper.fill(g2d, new RoundRectangle2D.Double(hintFrameX, hintFrameY, hintFrameWidth, hintFrameHeight, hintFrameRadius * 2, hintFrameRadius * 2));
g2d.setColor(HINT_FOREGROUND_COLOR);
GraphDrawHelper.drawString(g2d, hint, hintFrameX + (hintFrameWidth - hintTextWidth) / 2, hintFrameY + (hintFrameHeight + hintTextHeight) / 2.0 - metrics.getDescent());
} else {
if (height > hintFrameHeight) {
g2d.setColor(HINT_BACKGROUND_COLOR);
GraphDrawHelper.draw(g2d, new Line2D.Double(centerX, y + indent, centerX, y + height - indent), Constants.LINE_THIN, 1.0F);
GraphDrawHelper.draw(g2d, new Line2D.Double(centerX - shortLine, y + indent, centerX + shortLine, y + indent), Constants.LINE_THIN, 1.0F);
GraphDrawHelper.draw(g2d, new Line2D.Double(centerX - shortLine, y + height - indent, centerX + shortLine, y + height - indent), Constants.LINE_THIN, 1.0F);
}
double hintFrameX = centerX + HINT_GAP;
double hintFrameY = centerY - hintFrameHeight / 2;
g2d.setColor(HINT_BACKGROUND_COLOR);
GraphDrawHelper.fill(g2d, new RoundRectangle2D.Double(hintFrameX, hintFrameY, hintFrameWidth, hintFrameHeight, hintFrameRadius * 2, hintFrameRadius * 2));
hintField.setBounds((int) (centerX - width / 2.0), (int) (centerY - height / 2.0), (int) width, (int) height);
g2d.setColor(HINT_FOREGROUND_COLOR);
GraphDrawHelper.drawString(g2d, hint, hintFrameX + (hintFrameWidth - hintTextWidth) / 2, hintFrameY + (hintFrameHeight + hintTextHeight) / 2.0 - metrics.getDescent());
}
}
private void drawLine(Graphics2D g2d, Color backgroundColor, Color foregroundColor, double x1, double y1, double x2, double y2) {
g2d.setColor(backgroundColor);
GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_THIN, 2.0F);
private void drawDivider(Graphics2D g2d, double x1, double y1, double x2, double y2, boolean dragging) {
if (dragging) {
g2d.setColor(DIVIDER_BACKGROUND_COLOR);
GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_THIN, 2.0F);
g2d.setColor(foregroundColor);
GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_DASH, 1.0F);
g2d.setColor(DIVIDER_FOREGROUND_COLOR);
GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_THIN, 1.0F);
} else {
g2d.setColor(DIVIDER_BACKGROUND_COLOR);
GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_DASH, 1.0F);
}
}
@Override
@ -597,28 +661,22 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
int x = e.getX();
int y = e.getY();
int cursorType = getCursor().getType();
Cursor cursor = getCursor();
switch (cursorType) {
case Cursor.W_RESIZE_CURSOR: {
int nextLeft = (int) ((x - scaleImgX) / scale);
this.onNinePointLeftChanged(nextLeft);
return;
}
case Cursor.E_RESIZE_CURSOR: {
int nextRight = (int) ((scaleImgX + scaleImgWidth - x) / scale);
this.onNinePointRightChanged(nextRight);
return;
}
case Cursor.N_RESIZE_CURSOR: {
int nextTop = (int) ((y - scaleImgY) / scale);
this.onNinePointTopChanged(nextTop);
return;
}
case Cursor.S_RESIZE_CURSOR: {
int nextBottom = (int) ((scaleImgY + scaleImgHeight - y) / scale);
this.onNinePointBottomChanged(nextBottom);
}
if (cursor == W_DRAG_CURSOR || cursor == NW_DRAG_CURSOR || cursor == SW_DRAG_CURSOR) {
int nextLeft = (int) ((x - scaleImgX) / imageScale);
this.onNinePointLeftChanged(nextLeft);
} else if (cursor == E_DRAG_CURSOR || cursor == NE_DRAG_CURSOR || cursor == SE_DRAG_CURSOR) {
int nextRight = (int) ((scaleImgX + scaleImgWidth - x) / imageScale);
this.onNinePointRightChanged(nextRight);
}
if (cursor == N_DRAG_CURSOR || cursor == NE_DRAG_CURSOR || cursor == NW_DRAG_CURSOR) {
int nextTop = (int) ((y - scaleImgY) / imageScale);
this.onNinePointTopChanged(nextTop);
} else if (cursor == S_DRAG_CURSOR || cursor == SE_DRAG_CURSOR || cursor == SW_DRAG_CURSOR) {
int nextBottom = (int) ((scaleImgY + scaleImgHeight - y) / imageScale);
this.onNinePointBottomChanged(nextBottom);
}
}
@ -629,13 +687,13 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
int x = e.getX();
int y = e.getY();
double scaleLeft = ninePointLeft * scale;
double scaleTop = ninePointTop * scale;
double scaleRight = ninePointRight * scale;
double scaleBottom = ninePointBottom * scale;
double scaleLeft = ninePointLeft * imageScale;
double scaleTop = ninePointTop * imageScale;
double scaleRight = ninePointRight * imageScale;
double scaleBottom = ninePointBottom * imageScale;
// determine cursor
int cursorType = Cursor.DEFAULT_CURSOR;
Cursor cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
boolean hoveringLeftDivider = false;
boolean hoveringRightDivider = false;
@ -649,18 +707,31 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
hoveringBottomDivider = Math.abs(y - (scaleImgY + scaleImgHeight - scaleBottom)) < 2;
}
if (hoveringLeftDivider) {
cursorType = Cursor.W_RESIZE_CURSOR;
if (hoveringLeftDivider && hoveringTopDivider) {
cursor = NW_DRAG_CURSOR;
} else if (hoveringLeftDivider && hoveringBottomDivider) {
cursor = SW_DRAG_CURSOR;
} else if (hoveringRightDivider && hoveringTopDivider) {
cursor = NE_DRAG_CURSOR;
} else if (hoveringRightDivider && hoveringBottomDivider) {
cursor = SE_DRAG_CURSOR;
} else if (hoveringLeftDivider) {
cursor = W_DRAG_CURSOR;
} else if (hoveringRightDivider) {
cursorType = Cursor.E_RESIZE_CURSOR;
cursor = E_DRAG_CURSOR;
} else if (hoveringTopDivider) {
cursorType = Cursor.N_RESIZE_CURSOR;
cursor = N_DRAG_CURSOR;
} else if (hoveringBottomDivider) {
cursorType = Cursor.S_RESIZE_CURSOR;
cursor = S_DRAG_CURSOR;
}
needRepaint = getCursor().getType() != cursorType;
this.setCursor(Cursor.getPredefinedCursor(cursorType));
draggingLeftDivider = hoveringLeftDivider;
draggingRightDivider = hoveringRightDivider;
draggingTopDivider = hoveringTopDivider;
draggingBottomDivider = hoveringBottomDivider;
needRepaint = getCursor() != cursor;
this.setCursor(cursor);
if (needRepaint) {
repaint();
@ -680,6 +751,10 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
@Override
public void mouseReleased(MouseEvent e) {
this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
this.draggingLeftDivider = false;
this.draggingRightDivider = false;
this.draggingTopDivider = false;
this.draggingBottomDivider = false;
repaint();
}
@ -701,7 +776,6 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
value = imgHeight - ninePointBottom - MIN_NINE_POINT;
}
this.ninePointTop = value;
topField.setText(Integer.toString(value));
repaint();
}
@ -712,7 +786,6 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
value = imgHeight - ninePointTop - MIN_NINE_POINT;
}
this.ninePointBottom = value;
bottomField.setText(Integer.toString(value));
repaint();
}
@ -723,7 +796,6 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
value = imgWidth - ninePointRight - MIN_NINE_POINT;
}
this.ninePointLeft = value;
leftField.setText(Integer.toString(value));
repaint();
}
@ -734,32 +806,14 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
value = imgWidth - ninePointLeft - MIN_NINE_POINT;
}
this.ninePointRight = value;
rightField.setText(Integer.toString(value));
repaint();
}
private UIIntNumberField createNumberField() {
UIIntNumberField field = new UIIntNumberField();
field.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
field.setOpaque(true);
field.setMinValue(MIN_NINE_POINT);
field.setForeground(HINT_FOREGROUND_COLOR);
field.setBackground(HINT_BACKGROUND_COLOR);
field.setHorizontalAlignment(SwingConstants.CENTER);
return field;
}
public void setNinePoint(int[] ninePoint) {
ninePointLeft = ninePoint[0];
ninePointTop = ninePoint[1];
ninePointRight = ninePoint[2];
ninePointBottom = ninePoint[3];
leftField.setValue(ninePointLeft);
rightField.setValue(ninePointRight);
topField.setValue(ninePointTop);
bottomField.setValue(ninePointBottom);
}
public int[] getNinePoint() {

15
designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java

@ -3,9 +3,7 @@
*/
package com.fr.design.gui.xpane;
import com.fr.form.ui.LayoutBorderStyle;
import javax.swing.*;
import javax.swing.JPanel;
/**
* CardTagLayoutBorderPane Pane.
@ -14,14 +12,13 @@ public class CardTagLayoutStylePane extends LayoutStylePane {
@Override
protected JPanel createTitleStylePane(){
return null;
JPanel panel = super.createTitleStylePane();
panel.setVisible(false);
return panel;
}
@Override
public void updateTitle(LayoutBorderStyle style) {
protected JPanel createBackgroundStylePane(boolean supportCornerRadius) {
return super.createBackgroundStylePane(false);
}
@Override
protected void populateTitle() { }
}

122
designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java

@ -1,10 +1,8 @@
package com.fr.design.gui.xpane;
import com.fr.base.GraphHelper;
import com.fr.base.Utils;
import com.fr.base.svg.IconUtils;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.formula.TinyFormulaPane;
@ -13,7 +11,6 @@ import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
@ -91,7 +88,14 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
//标题背景透明度
protected UIPercentDragPane titleBackgroundOpacityPane;
private boolean supportBorderImage = false;
public LayoutStylePane() {
this(false);
}
public LayoutStylePane(boolean supportBorderImage) {
this.supportBorderImage = supportBorderImage;
this.initLayout();
}
@ -105,42 +109,51 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
boolean currentIsRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane();
JPanel titlePane = createTitleStylePane();
JPanel bodyContentPane = currentIsRootLayout ? createBodyContentPane4RootLayout() : createBodyContentPane();
JPanel backgroundPane = createBackgroundStylePane(true);
if (titlePane != null) {
container.add(titlePane, BorderLayout.NORTH);
if (currentIsRootLayout) {
titlePane.setVisible(false);
}
}
JPanel nextContainerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.add(nextContainerPane, BorderLayout.CENTER);
//界面上表单主体只有背景和透明度可以设置
JPanel mainStylePane = currentIsRootLayout ? createMainStylePane4RootLayout() : createMainStylePane4WidgetLayout();
if (mainStylePane != null) {
container.add(mainStylePane, BorderLayout.CENTER);
if (bodyContentPane != null) {
//界面上表单主体只有背景和透明度可以设置
nextContainerPane.add(bodyContentPane, BorderLayout.NORTH);
}
if (backgroundPane != null) {
nextContainerPane.add(backgroundPane, BorderLayout.CENTER);
if (currentIsRootLayout) {
backgroundPane.setVisible(false);
}
}
this.add(container, BorderLayout.CENTER);
}
protected void initMainComponents() {
protected JPanel createBackgroundStylePane(boolean supportCornerRadius) {
borderStyleCombo = new UIComboBox(BORDER_STYLE);
borderLineAndImagePane = new BorderLineAndImagePane();
borderLineAndImagePane = new BorderLineAndImagePane(this.supportBorderImage);
cornerSpinner = new UISpinner(0,1000,1,0);
backgroundPane = new LayoutBackgroundSpecialPane();
backgroundOpacityPane = new UIPercentDragPane();
}
protected JPanel createMainStylePane4WidgetLayout() {
initMainComponents();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p, p, p, p, p};
double[] rowSize = supportCornerRadius ? new double[] {p, p, p, p} : new double[]{p, p, p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Background_Style"));
Font font = uiLabel.getFont().deriveFont(Font.BOLD);
uiLabel.setFont(font);
uiLabel.setForeground(new Color(143, 143, 146));
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame_Style")), null},
{uiLabel, null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo},
{this.borderLineAndImagePane, null},
{this.createMainBackgroundAndOpacityPane(), null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner},
},
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
@ -153,16 +166,27 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
return container;
}
protected JPanel createMainStylePane4RootLayout() {
initMainComponents();
protected JPanel createBodyContentPane() {
backgroundPane = new LayoutBackgroundSpecialPane();
backgroundOpacityPane = new UIPercentDragPane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p, p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel bodyBackground = createBackgroundAndOpacityPane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill"),
this.backgroundPane,
this.backgroundOpacityPane);
UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Content"));
Font font = uiLabel.getFont().deriveFont(Font.BOLD);
uiLabel.setFont(font);
uiLabel.setForeground(new Color(143, 143, 146));
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame_Style")), null},
{this.createMainBackgroundAndOpacityPane(), null},
{uiLabel, null},
{bodyBackground, null},
},
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
@ -174,11 +198,31 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
return container;
}
protected JPanel createMainBackgroundAndOpacityPane() {
return createBackgroundAndOpacityPane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Background"),
protected JPanel createBodyContentPane4RootLayout() {
backgroundPane = new LayoutBackgroundSpecialPane();
backgroundOpacityPane = new UIPercentDragPane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel bodyBackground = createBackgroundAndOpacityPane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill"),
this.backgroundPane,
this.backgroundOpacityPane);
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{bodyBackground, null},
},
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setBorder(new BottomLineBorder());
container.add(contentPane, BorderLayout.NORTH);
return container;
}
protected void initTitleComponents() {
@ -187,6 +231,15 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
titleTextPane = new TinyFormulaPane();
titleFontFamilyComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
TitlePacker title = style.getTitle();
if (title != null) {
FRFont frFont = title.getFrFont();
if (frFont != null) {
String fontFamily = frFont.getFamily();
// 使用style中默认的字体初始化titleFontFamilyComboBox,保证UI和数据的一致性
this.titleFontFamilyComboBox.setSelectedItem(fontFamily);
}
}
titleFontFamilyComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Family"));
titleFontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES);
@ -261,8 +314,12 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
visibleComposedPane.add(titleVisibleCheckbox, BorderLayout.WEST);
visibleComposedPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Visible")), BorderLayout.CENTER);
UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title"));
Font font = uiLabel.getFont().deriveFont(Font.BOLD);
uiLabel.setFont(font);
uiLabel.setForeground(new Color(143, 143, 146));
JPanel topPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][] {
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title")), null},
{uiLabel, null},
{visibleComposedPane, null}
}, new double[]{p, p}, new double[]{SETTING_LABEL_WIDTH, p}, IntervalConstants.INTERVAL_L1);
topPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
@ -489,16 +546,25 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
protected static class BottomLineBorder extends LineBorder {
public BottomLineBorder() {
super(Color.lightGray, 1);
super(new Color(217, 218, 221), 1);
}
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Graphics2D g2d = (Graphics2D) g;
Color oldColor = g2d.getColor();
g2d.setColor(this.lineColor);
GraphHelper.drawLine(g, 0, height, width, height, 1);
Stroke oldStroke = g2d.getStroke();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(getLineColor());
g2d.setStroke(new BasicStroke(getThickness() * 2));
g2d.drawLine(0, height, width, height);
g2d.setStroke(oldStroke);
g2d.setColor(oldColor);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
}

59
designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java

@ -35,7 +35,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.RoundRectangle2D;
/**
@ -57,6 +56,7 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
private UIButton imageChooseButton;
private UIButton imageDeleteButton;
private ImagePreviewPane imagePreviewPane;
private JPanel imagePreviewOverlayPane;
private UIButtonGroup<Integer> imageLocationPane;
private UISpinner imagePaddingPane;
@ -89,24 +89,31 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
deletableImagePreviewPane.setLayout(null);
deletableImagePreviewPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
deletableImagePreviewPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE));
JPanel overlayPane = new JPanel();
overlayPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE - 2, IMAGE_PREVIEW_SIZE - 2));
overlayPane.setBackground(IMAGE_PREVIEW_OVERLAY_COLOR);
imagePreviewOverlayPane = new JPanel();
imagePreviewOverlayPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE - 2, IMAGE_PREVIEW_SIZE - 2));
imagePreviewOverlayPane.setBackground(IMAGE_PREVIEW_OVERLAY_COLOR);
imagePreviewPane.setBounds(0, 0, IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE);
overlayPane.setBounds(1, 1, IMAGE_PREVIEW_SIZE - 2, IMAGE_PREVIEW_SIZE - 2);
imagePreviewOverlayPane.setBounds(1, 1, IMAGE_PREVIEW_SIZE - 2, IMAGE_PREVIEW_SIZE - 2);
imageDeleteButton.setBounds(IMAGE_PREVIEW_SIZE - DELETE_BUTTON_SIZE, 0, DELETE_BUTTON_SIZE, DELETE_BUTTON_SIZE);
deletableImagePreviewPane.add(imageDeleteButton, 0);
deletableImagePreviewPane.add(overlayPane, 1);
deletableImagePreviewPane.add(imagePreviewPane, 2);
overlayPane.setVisible(false);
JPanel mousePane = new JPanel();
mousePane.setBounds(0, 0, IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE);
mousePane.setOpaque(false);
mousePane.setBackground(null);
deletableImagePreviewPane.add(mousePane, 0);
deletableImagePreviewPane.add(imageDeleteButton, 1);
deletableImagePreviewPane.add(imagePreviewOverlayPane, 2);
deletableImagePreviewPane.add(imagePreviewPane, 3);
imagePreviewOverlayPane.setVisible(false);
imageDeleteButton.setVisible(false);
imageDeleteButton.setEnabled(false);
deletableImagePreviewPane.addMouseListener(new MouseAdapter() {
mousePane.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
super.mouseEntered(e);
overlayPane.setVisible(true);
imagePreviewOverlayPane.setVisible(true);
imageDeleteButton.setVisible(true);
imageDeleteButton.setEnabled(true);
}
@ -114,12 +121,27 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
@Override
public void mouseExited(MouseEvent e) {
super.mouseExited(e);
imagePreviewOverlayPane.setVisible(false);
imageDeleteButton.setVisible(false);
imageDeleteButton.setEnabled(false);
}
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
int x = e.getX();
int y = e.getY();
if (x <= 0 || getWidth() <= x || y <= 0 || y >= getHeight()) {
overlayPane.setVisible(false);
Rectangle bounds = imageDeleteButton.getBounds();
if (bounds.x < x && x < bounds.x + bounds.width && bounds.y < y && y < bounds.y + bounds.height) {
imagePreviewPane.setImageWithSuffix(null);
imageLocationPane.setSelectedIndex(DEFAULT_INSET_LOCATION_INDEX);
imagePaddingPane.setValue(DEFAULT_INSET_PADDING);
imagePreviewOverlayPane.setVisible(false);
imageDeleteButton.setVisible(false);
imageDeleteButton.setEnabled(false);
getComponent(1).setVisible(false);
fireStateChanged();
}
}
});
@ -210,17 +232,6 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
}).dealWithImageFile(returnVal);
}
});
this.imageDeleteButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
imagePreviewPane.setImageWithSuffix(null);
imageLocationPane.setSelectedIndex(DEFAULT_INSET_LOCATION_INDEX);
imagePaddingPane.setValue(DEFAULT_INSET_PADDING);
getComponent(1).setVisible(false);
fireStateChanged();
}
});
}
public void populateBean(TitlePacker packer) {

29
designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java

@ -4,7 +4,9 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.treeview.ComponentTreeCellRenderer;
import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.design.file.HistoryTemplateListCache;
@ -406,6 +408,14 @@ public class ComponentTree extends JTree {
@Override
public void mouseReleased(MouseEvent e) {
if (e.isControlDown() || e.isShiftDown()) {
return;
}
XCreator currentCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
// 以当前选中的为准
if (currentCreator != selectedCreator) {
selectedCreator = currentCreator;
}
if (e.getButton() == MouseEvent.BUTTON1 && selectedCreator != null) {
showSelectedPopup(selectedCreator);
}
@ -413,7 +423,7 @@ public class ComponentTree extends JTree {
private void showSelectedPopup(XCreator comp) {
Rectangle rectangle = getRelativeBounds(comp);
comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class));
comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class, XWCardMainBorderLayout.class, XWAbsoluteLayout.class));
comp.setSelected(true);
}
@ -424,6 +434,9 @@ public class ComponentTree extends JTree {
* @param consumer
*/
private void onMouseEvent(final MouseEvent e, Consumer<XCreator> consumer) {
if (e.isControlDown() || e.isShiftDown()) {
return;
}
Point p = e.getPoint();
// 解析组件树路径 获取选中的组件
int selRow = tree.getRowForLocation(p.x, p.y);
@ -453,6 +466,20 @@ public class ComponentTree extends JTree {
if (ArrayUtils.isNotEmpty(listeners) && listeners[0] instanceof EditingMouseListener) {
responseClickAll(creator, (EditingMouseListener) listeners[0], new MouseEvent(creator, MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), x, y, e.getClickCount(), false));
}
// 放到事件尾部执行
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
//处理下tab块的选中
if (comp.acceptType(XWCardMainBorderLayout.class)) {
XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
if (xCreator != null) {
showSelectedPopup(xCreator);
}
}
}
});
}
/**

31
designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java

@ -2,12 +2,13 @@ package com.fr.design.mainframe;
import com.fr.base.GraphHelper;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.icon.IconPathConstants;
import com.fr.general.IOUtils;
import com.fr.stable.Constants;
import java.awt.BasicStroke;
import java.awt.Stroke;
import javax.swing.JComponent;
import java.awt.AlphaComposite;
import java.awt.Color;
@ -32,6 +33,8 @@ public class CoverPane extends JComponent {
protected static final int BORDER_WIDTH = 2;
public static final int EDIT_BTN_W = 75;
public static final int EDIT_BTN_H = 20;
private static final int BORDER_GAP = 2;
private static final BasicStroke BORDER_STROKE = new BasicStroke(2f);
public static void paintEditButton(Graphics g, Component component) {
int x = 0;
@ -42,9 +45,7 @@ public class CoverPane extends JComponent {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
//画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 50 / 100.0F));
g2d.setColor(XCreatorConstants.COVER_COLOR);
g2d.fillRect(x, y, w, h);
paintCover(g, component);
//画编辑按钮所在框
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, formDesigner.getCursor().getType() != Cursor.DEFAULT_CURSOR ? 0.9f : 0.7f);
@ -71,6 +72,26 @@ public class CoverPane extends JComponent {
GraphHelper.draw(g, new Rectangle(BORDER_WIDTH, BORDER_WIDTH, w - BORDER_WIDTH * 2, h - BORDER_WIDTH * 2), Constants.LINE_MEDIUM);
}
/**
* 绘制悬浮层
* @param g
* @param component
*/
public static void paintCover(Graphics g, Component component) {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
//画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 50 / 100.0F));
g2d.setColor(XCreatorConstants.COVER_COLOR);
g2d.fillRect(0, 0, component.getWidth(), component.getHeight());
g2d.setComposite(oldComposite);
g2d.setColor(XCreatorConstants.FORM_BORDER_COLOR);
Stroke oldStroke = g2d.getStroke();
g2d.setStroke(BORDER_STROKE);
g2d.drawRect(BORDER_GAP, BORDER_GAP, component.getWidth() - BORDER_GAP * 2, component.getHeight() - BORDER_GAP * 2);
g2d.setStroke(oldStroke);
}
public CoverPane() {
setBackground(null);
setOpaque(false);
@ -87,6 +108,6 @@ public class CoverPane extends JComponent {
public void paint(Graphics g) {
super.paint(g);
paintEditButton(g, this);
paintCover(g, this);
}
}

3
designer-form/src/main/java/com/fr/design/mainframe/CoverReportPane.java

@ -75,8 +75,5 @@ public class CoverReportPane extends CoverPane{
@Override
public void paint(Graphics g) {
super.paint(g);
if (isShared()) {
paintShareButton(g, this);
}
}
}

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

@ -18,7 +18,9 @@ import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XEditorHolder;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.designer.creator.cardlayout.XCardAddButton;
import com.fr.design.designer.creator.cardlayout.XCardSwitchButton;
import com.fr.design.designer.creator.cardlayout.XWCardLayout;
@ -34,6 +36,7 @@ import com.fr.design.utils.gui.LayoutUtils;
import com.fr.general.ComparatorUtils;
import com.fr.stable.Constants;
import java.util.LinkedList;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPopupMenu;
@ -382,6 +385,14 @@ public class EditingMouseListener extends MouseInputAdapter {
}
private boolean isEditButton(MouseEvent e, XCreator component, Insets insets) {
// 不显示编辑按钮 鼠标格式
if (component.getParent() instanceof XCreator) {
XCreator parent = (XCreator) component.getParent();
if (parent.acceptType(XWTitleLayout.class) || component.acceptType(XWCardMainBorderLayout.class, XWAbsoluteLayout.class)) {
return false;
}
}
int innerWidth = component.getWidth() - insets.left - insets.right;
int innerHeight = component.getHeight() - insets.top - insets.bottom;
@ -457,10 +468,7 @@ public class EditingMouseListener extends MouseInputAdapter {
if (designer.getCursor().getType() == Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
if (isShareConfigButton(e, component, insets)) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
component.setHelpBtnOnFocus(true);
} else if (isEditButton(e, component, insets)) {
if (isEditButton(e, component, insets)) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
}
@ -613,6 +621,7 @@ public class EditingMouseListener extends MouseInputAdapter {
int oldX = e.getX();
int oldY = e.getY();
offsetEventPoint(e);
selectionModel.getSelection().getTabList().clear();
XCreator creator = designer.getComponentAt(e);
boolean isValidButton = e.getButton() == MouseEvent.BUTTON1 || e.getButton() == MouseEvent.BUTTON3;
@ -638,7 +647,7 @@ public class EditingMouseListener extends MouseInputAdapter {
@Override
public void run() {
for (XCreator xCreator : xCreators) {
xCreator.setSelected(true);
xCreator.setSelected(!e.isShiftDown() && !e.isControlDown());
}
}
});
@ -661,13 +670,36 @@ public class EditingMouseListener extends MouseInputAdapter {
}
private boolean responseTabLayout(XCreator creator, MouseEvent e) {
if (creator.acceptType(XWCardMainBorderLayout.class) ) {
creator.respondClick(this, e);
LinkedList<XCreator> list = selectionModel.getSelection().getTabList();
if (creator.acceptType(XWCardMainBorderLayout.class)) {
list.add(creator);
}
while (creator.getParent() instanceof XCreator) {
creator = (XCreator) creator.getParent();
if (creator.acceptType(XWCardMainBorderLayout.class)) {
list.add(creator);
}
}
// 至少存在一层以上tab块的嵌套
if (list.size() > 1) {
XWCardMainBorderLayout firstCreator = (XWCardMainBorderLayout) list.getFirst();
XWCardMainBorderLayout lastCreator = (XWCardMainBorderLayout) list.getLast();
// 内层tab响应事件
firstCreator.respondClick(this, e);
setCoverPaneNotDisplay(firstCreator, e, false);
final XCreator xCreator = selectionModel.getSelection().getSelectedCreator();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
xCreator.setSelected(true);
// 外层tab展示阴影边框效果
lastCreator.setShowOuterShadowBorder(true);
}
});
return true;
} else if (creator.getParent() instanceof XCreator) {
return responseTabLayout((XCreator) creator.getParent(), e);
} else {
return false;
}
return false;
}

12
designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -112,7 +112,12 @@ public class FormCreatorDropTarget extends DropTarget {
if (addingXCreator.isShared()) {
if (container.acceptType(XWAbsoluteLayout.class)) {
// 绝对布局中新添加的共享组件默认锁定尺寸比例
addingXCreator.toData().setAspectRatioLocked(true);
Rectangle bounds = new Rectangle(addingXCreator.getBounds());
Widget addingWidget = addingXCreator.toData();
if (addingWidget != null && bounds.width > 0 && bounds.height > 0) {
addingXCreator.toData().setAspectRatioLocked(true);
addingXCreator.toData().setAspectRatioBackup(1.0 * bounds.width / bounds.height);
}
}
String shareId = addingXCreator.getShareId();
@ -140,6 +145,11 @@ public class FormCreatorDropTarget extends DropTarget {
tabDragInner.tryDragIn();
} else {
Toolkit.getDefaultToolkit().beep();
// 拖入失败 取消选中
XCreator creator = addingModel.getXCreator();
if (creator != null) {
creator.setSelected(false);
}
}
// 取消提示
designer.setPainter(null);

14
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -1743,4 +1743,18 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return false;
}
public void processPopup(boolean canVisible) {
XCreator creator = this.getSelectionModel().getSelection().getSelectedCreator();
if (creator != null) {
creator.processPopup(canVisible);
}
}
public void hidePopup() {
XCreator creator = this.getSelectionModel().getSelection().getSelectedCreator();
if (creator != null) {
creator.hidePopup();
}
}
}

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

@ -95,7 +95,7 @@ public class FormDesignerUI extends ComponentUI {
}
paintBorder(g);
paintSelection(g);
paintDropBorderShadow(g);
paintBorderShadow(g);
if (DesignerMode.isAuthorityEditing()) {
paintAuthorityDetails(g, designer.getRootComponent());
@ -333,22 +333,34 @@ public class FormDesignerUI extends ComponentUI {
}
/**
* 绘制可拖拽进tab块之前的阴影
* 绘制tab块的阴影
*
* @param g
*/
private void paintDropBorderShadow(Graphics g) {
private void paintBorderShadow(Graphics g) {
// 绘制可拖拽进tab块之前的阴影
DropTarget dropTarget = designer.getDropTarget();
if (dropTarget instanceof FormCreatorDropTarget) {
FormCreatorDropTarget target = (FormCreatorDropTarget) dropTarget;
XLayoutContainer layoutContainer = target.getTabDragInner().getBelowXLayoutContainer();
if (layoutContainer != null && layoutContainer.acceptType(XWCardMainBorderLayout.class)) {
Rectangle creatorBounds = ComponentUtils.getRelativeBounds(layoutContainer);
creatorBounds.x -= designer.getHorizontalScaleValue();
creatorBounds.y -= designer.getVerticalScaleValue();
layoutContainer.paintBorder(g, creatorBounds);
XWCardMainBorderLayout cardMainBorderLayout = (XWCardMainBorderLayout) layoutContainer;
cardMainBorderLayout.paintShadowBorder(g, getCreatorBounds(layoutContainer));
}
}
// 绘制嵌套tab块时的阴影
if (designer.getSelectionModel().getSelection().getTabList().size() > 1) {
XLayoutContainer layoutContainer = (XLayoutContainer) designer.getSelectionModel().getSelection().getTabList().getLast();
XWCardMainBorderLayout cardMainBorderLayout = (XWCardMainBorderLayout) layoutContainer;
cardMainBorderLayout.paintShadowBorder(g, getCreatorBounds(layoutContainer));
}
}
private Rectangle getCreatorBounds(XLayoutContainer layoutContainer) {
Rectangle creatorBounds = ComponentUtils.getRelativeBounds(layoutContainer);
creatorBounds.x -= designer.getHorizontalScaleValue();
creatorBounds.y -= designer.getVerticalScaleValue();
return creatorBounds;
}
/**

11
designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java

@ -13,6 +13,7 @@ import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.file.HistoryTemplateListCache;
@ -25,12 +26,15 @@ import java.awt.Component;
import java.awt.LayoutManager;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.LinkedList;
public class FormSelection {
private ArrayList<XCreator> selection;
private Rectangle backupBounds;
private ArrayList<Rectangle> recs = new ArrayList<Rectangle>();
// 选中的组件外层嵌套的tab块 head->tail 由内向外
private LinkedList<XCreator> tabList = new LinkedList<>();
public FormSelection() {
selection = new ArrayList<XCreator>();
@ -43,6 +47,9 @@ public class FormSelection {
for (XCreator xCreator : selection) {
xCreator.setSelected(false);
}
for (XCreator xCreator : tabList) {
((XWCardMainBorderLayout) xCreator).setShowOuterShadowBorder(false);
}
selection.clear();
}
@ -404,4 +411,8 @@ public class FormSelection {
}
}
}
public LinkedList<XCreator> getTabList() {
return tabList;
}
}

30
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -89,8 +89,6 @@ import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory;
import com.fr.web.controller.ViewRequestConstants;
import java.awt.event.ContainerAdapter;
import java.awt.event.ContainerEvent;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JComponent;
@ -133,36 +131,16 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
//FORM_TAB代表是否点击编辑,用于点击编辑前后菜单的显示
protected int index = FORM_TAB;
private ContainerAdapter containerAdapter = new ContainerAdapter() {
@Override
public void componentRemoved(ContainerEvent e) {
// 当前jfrom未在tab中显示时
if (formDesign != null) {
XCreator[] creators = formDesign.getSelectionModel().getSelection().getSelectedCreators();
for (XCreator creator : creators) {
creator.hidePopup();
}
}
}
};
public JForm() {
super(new Form(new WBorderLayout("form")), "Form");
init();
}
public JForm(Form form, FILE file, Parameter[] parameters) {
super(form, file, parameters);
init();
}
public JForm(Form form, FILE file) {
super(form, file);
init();
}
private void init() {
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().addContainerListener(containerAdapter);
}
@Override
@ -1130,7 +1108,6 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
public void whenClose() {
super.whenClose();
this.releaseResources();
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().removeContainerListener(this.containerAdapter);
}
@Override
@ -1151,4 +1128,11 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
}, XElementCase.class);
}
}
@Override
public void fireTabChange() {
if (formDesign != null) {
formDesign.hidePopup();
}
}
}

18
designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java

@ -150,6 +150,11 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane {
freshPropertyMode(innerCreator);
if (isExtraWidget) {
// REPORT-55603: 仅对于插件控件,将尺寸*位置面板放置在definePane下方,其余控件将尺寸*位置面板放置在definePane上方
widgetBoundPane = createWidgetBoundPane(xCreator);
if (widgetBoundPane != null) {
attriCardPane.add(widgetBoundPane, BorderLayout.CENTER);
}
return;
}
@ -187,9 +192,18 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane {
});
DataModify<Widget> definePane = rn.getDefinePane();
JComponent jComponent = definePane.toSwingComponent();
JComponent definePaneComponent = definePane.toSwingComponent();
boolean isExtraWidget = FormWidgetDefinePaneFactoryBase.isExtraXWidget(creator.toData());
attriCardPane.add(jComponent, BorderLayout.CENTER);
if (isExtraWidget) {
// REPORT-55603: 仅对于插件控件,将尺寸*位置面板放置在definePane下方,其余控件将尺寸*位置面板放置在definePane上方
attriCardPane.add(definePaneComponent, BorderLayout.NORTH);
} else {
// 使用单独的JPane和BorderLayout.North进行包装,避免出现CENTER嵌套CENTER后,内容高度变大的情况
JPanel definePaneWrapContent = FRGUIPaneFactory.createBorderLayout_S_Pane();
definePaneWrapContent.add(definePaneComponent, BorderLayout.NORTH);
attriCardPane.add(definePaneWrapContent, BorderLayout.CENTER);
}
currentEditorDefinePane = definePane;
}

4
designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java

@ -132,6 +132,10 @@ public class FormWidgetDefinePaneFactoryBase {
defineMap.put(widget, appearance);
}
public static Appearance getDefinePane(Class<? extends Widget> widget) {
return defineMap.get(widget);
}
public static RN createWidgetDefinePane(XCreator creator, FormDesigner designer, Widget widget, Operator operator) {
if (isExtraXWidget(widget)) {
WidgetDefinePane widgetDefinePane = new WidgetDefinePane(creator, designer);

6
designer-form/src/main/java/com/fr/design/widget/ui/designer/component/UIBoundSpinner.java

@ -23,8 +23,14 @@ public class UIBoundSpinner extends UISpinner{
@Override
protected void initTextFiledListeners(){
this.getTextField().addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
setTextFieldFocus(true);
}
@Override
public void focusLost(FocusEvent e) {
setTextFieldFocus(false);
setTextFieldValue(getTextField().getValue());
setTextField(value);
}

70
designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java

@ -103,14 +103,11 @@ public class WidgetBoundPane extends BasicPane {
}
public void populate() {
Rectangle bounds = new Rectangle(creator.getBounds());
if (ratioLockedButton != null) {
// 临时禁止尺寸比例锁定,关掉widthSpinner/heightSpinner之间的数值关联,以更新其高度和宽度值
ratioLockedButton.setLocked(false);
}
width.setValue(bounds.width);
height.setValue(bounds.height);
if (ratioLockedButton != null) {
if (ratioLockedButton == null) {
Rectangle bounds = new Rectangle(creator.getBounds());
width.setValue(bounds.width);
height.setValue(bounds.height);
} else {
ratioLockedButton.populate(creator);
}
}
@ -213,8 +210,7 @@ public class WidgetBoundPane extends BasicPane {
private final UISpinner mWidthSpinner;
private final UISpinner mHeightSpinner;
protected double width4Backup = 0;
protected double height4Backup = 0;
protected double aspectRatioBackup = 0;
public AspectRatioLockedButton(UISpinner widthSpinner, UISpinner heightSpinner) {
setUI(new BasicButtonUI());
@ -229,12 +225,16 @@ public class WidgetBoundPane extends BasicPane {
addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// 改变图标icon
setLocked(!isLocked());
if (isLocked() && isLockEnabled()) {
width4Backup = mWidthSpinner.getValue();
height4Backup = mHeightSpinner.getValue();
double width = mWidthSpinner.getValue();
double height = mHeightSpinner.getValue();
boolean nextLocked = !isLocked();
if (nextLocked && width > 0 && height > 0) {
setLocked(true);
aspectRatioBackup = width / height;
} else {
setLocked(false);
aspectRatioBackup = -1;
}
if (globalNameListener != null) {
@ -250,16 +250,28 @@ public class WidgetBoundPane extends BasicPane {
mWidthSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (isLockEnabled() && isLocked() && width4Backup > 0 && height4Backup > 0) {
mHeightSpinner.setValue(mWidthSpinner.getValue() * height4Backup / width4Backup, false);
if (isLockEnabled() && isLocked()) {
if (mWidthSpinner.getValue() == 0) {
setLocked(false);
aspectRatioBackup = -1;
} else if (aspectRatioBackup > 0) {
double value = mWidthSpinner.getValue() / aspectRatioBackup;
mHeightSpinner.setValue(Math.round(value), false);
}
}
}
});
mHeightSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (isLockEnabled() && isLocked() && width4Backup > 0 && height4Backup > 0) {
mWidthSpinner.setValue(mHeightSpinner.getValue() * width4Backup / height4Backup, false);
if (isLockEnabled() && isLocked()) {
if (mHeightSpinner.getValue() == 0) {
setLocked(false);
aspectRatioBackup = -1;
}else if (aspectRatioBackup > 0) {
double value = mHeightSpinner.getValue() * aspectRatioBackup;
mWidthSpinner.setValue(Math.round(value), false);
}
}
}
});
@ -301,14 +313,26 @@ public class WidgetBoundPane extends BasicPane {
public void populate(XCreator creator) {
Rectangle bounds = new Rectangle(creator.getBounds());
width4Backup = bounds.width;
height4Backup = bounds.height;
Widget widget = creator.toData();
aspectRatioBackup = widget.getAspectRatioBackup();
setLocked(widget.isAspectRatioLocked());
mWidthSpinner.setValue(bounds.width, false);
mHeightSpinner.setValue(bounds.height, false);
}
public void update(XCreator creator) {
creator.toData().setAspectRatioLocked(this.isLocked());
Widget widget = creator.toData();
if (widget != null) {
if (this.isLocked()) {
widget.setAspectRatioLocked(true);
widget.setAspectRatioBackup(this.aspectRatioBackup);
} else {
widget.setAspectRatioLocked(false);
widget.setAspectRatioBackup(-1.0);
}
}
}
@Override

2
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java

@ -27,7 +27,7 @@ public abstract class WTitleLayoutDefinePane<T extends AbstractBorderStyleWidget
public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel advancePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
stylePane = new LayoutStylePane();
stylePane = new LayoutStylePane(true);
advancePane.add(stylePane, BorderLayout.NORTH);
JPanel centerPane = createCenterPane();
if(centerPane!=null){

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

@ -198,6 +198,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
centerPane = new UIModeControlContainer(parameterPane, reportComposite = new ReportComponentComposite(this)) {
@Override
protected void onModeChanged() {
processPopup(isUpMode());
refreshToolArea();
}
@ -1221,4 +1222,19 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
super.whenClose();
reportComposite.doRemoveAction();
}
protected void processPopup(boolean visible) {
FormDesigner designer = (FormDesigner) parameterPane.getParaDesigner();
if (designer != null) {
designer.processPopup(visible);
}
}
@Override
public void fireTabChange() {
FormDesigner designer = (FormDesigner) parameterPane.getParaDesigner();
if (designer != null) {
designer.hidePopup();
}
}
}

42
designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java

@ -30,6 +30,7 @@ import com.fr.design.selection.Selectedable;
import com.fr.design.selection.SelectionListener;
import com.fr.form.FormElementCaseProvider;
import com.fr.form.main.Form;
import com.fr.grid.Grid;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection;
import com.fr.log.FineLoggerFactory;
@ -44,7 +45,8 @@ import javax.swing.JScrollBar;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
/**
@ -128,17 +130,33 @@ public class FormElementCaseDesigner
public BufferedImage getElementCaseImage(Dimension size) {
BufferedImage image = null;
try {
image = new java.awt.image.BufferedImage(size.width, size.height,
java.awt.image.BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
//填充白色背景, 不然有黑框
Color oldColor = g.getColor();
g.setColor(Color.WHITE);
g.fillRect(0, 0, size.width, size.height);
g.setColor(oldColor);
this.elementCasePane.paintComponents(g);
int width = size.width;
int height = size.height;
// 使用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
image = g2d.getDeviceConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT);
g2d.dispose();
g2d = image.createGraphics();
// 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image,
// 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0)
// 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图
g2d.setColor(new Color(255, 255, 255, 1));
g2d.fillRect(0, 0, (int) size.getWidth(), (int) size.getHeight());
Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null;
if (grid != null) {
boolean oldTranslucent = grid.isTranslucent();
// 截缩图图时grid需支持半透明,不能用默认白色填充画布,否则会遮挡组件样式背景
grid.setTranslucent(true);
grid.paint(g2d);
grid.setTranslucent(oldTranslucent);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);

53
designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

@ -32,6 +32,8 @@ import javax.swing.*;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.Timer;
import java.util.TimerTask;
public class DesignerSocketIO {
@ -45,7 +47,7 @@ public class DesignerSocketIO {
if (DesignerEnvManager.getEnvManager().isHttps()) {
showConnectionLostDialog();
}
}
}
});
}
@ -57,6 +59,8 @@ public class DesignerSocketIO {
private static Socket socket = null;
private static Status status = Status.Disconnected;
private static Timer disConnectHintTimer = null;
private static long disConnectHintTimerDelay = 3000;
//维护一个当前工作环境的uri列表
private static String[] uri;
//维护一个关于uri列表的计数器
@ -87,18 +91,19 @@ public class DesignerSocketIO {
createSocket();
}
private static void createSocket(){
private static void createSocket() {
//根据uri和计数器建立连接,并注册监听
try {
if(count<uri.length) {
if (count < uri.length) {
socket = IO.socket(new URI(uri[count]));
socket.on(WorkspaceConstants.WS_LOGRECORD, printLog);
socket.on(WorkspaceConstants.CONFIG_MODIFY, modifyConfig);
socket.on(Socket.EVENT_CONNECT_ERROR, failRetry);
socket.on(Socket.EVENT_DISCONNECT, disConnectHint);
socket.on(Socket.EVENT_CONNECT, handleConnect);
socket.connect();
status = Status.Connected;
}else {
} else {
//表示所有的uri都连接不成功
FineLoggerFactory.getLogger().warn("All uris failed to connect");
}
@ -154,19 +159,41 @@ public class DesignerSocketIO {
}
};
private static final Emitter.Listener handleConnect = new Emitter.Listener() {
@Override
public void call(Object... objects) {
if (disConnectHintTimer != null) {
FineLoggerFactory.getLogger().info("cancel disConnectHintTimer");
disConnectHintTimer.cancel();
}
}
};
//断开连接提醒监听器
private static final Emitter.Listener disConnectHint = new Emitter.Listener() {
@Override
public void call(Object... objects) {
/*
* todo 远程心跳断开不一定 socket 断开 和远程紧密相关的业务都绑定在心跳上切换成心跳断开之后进行提醒
* socket 只用推日志和通知配置变更
*/
FineLoggerFactory.getLogger().error("disConnected args: {}", Arrays.toString(objects));
if (status != Status.Disconnecting) {
showConnectionLostDialog();
}
status = Status.Disconnected;
FineLoggerFactory.getLogger().info("start disConnectHintTimer");
disConnectHintTimer = new Timer();
disConnectHintTimer.schedule(new TimerTask() {
@Override
public void run() {
try {
/*
* todo 远程心跳断开不一定 socket 断开 和远程紧密相关的业务都绑定在心跳上切换成心跳断开之后进行提醒
* socket 只用推日志和通知配置变更
*/
FineLoggerFactory.getLogger().error("disConnected args: {}", Arrays.toString(objects));
if (status != Status.Disconnecting) {
showConnectionLostDialog();
}
status = Status.Disconnected;
} finally {
disConnectHintTimer.cancel();
disConnectHintTimer = null;
}
}
}, disConnectHintTimerDelay);
}
};

33
designer-realize/src/main/java/com/fr/design/share/SharableManager.java

@ -10,14 +10,21 @@ import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.collect.SharableCollectorManager;
import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptSelectionClipboardHandler;
import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptTransferableClipboardHandler;
import com.fr.design.mainframe.share.ui.block.LocalWidgetBlock;
import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane;
import com.fr.design.mainframe.share.util.ShareComponentUtils;
import com.fr.design.share.utils.EffectItemUtils;
import com.fr.form.share.ShareLoader;
import com.fr.design.widget.FormWidgetDefinePaneFactoryBase;
import com.fr.form.share.encrypt.engine.ClazzCreatorFactory;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.GeneralContext;
import com.fr.json.JSONArray;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.bridge.BridgeMark;
import com.fr.stable.bridge.StableFactory;
import java.util.List;
@ -27,6 +34,7 @@ public class SharableManager {
listenEnv();
ClipboardFilter.registerClipboardHandler(EncryptSelectionClipboardHandler.getInstance());
ClipboardFilter.registerClipboardHandler(EncryptTransferableClipboardHandler.getInstance());
registerSharableEncryptDefinePanes();
}
public static void saveTemplate(JTemplate jt) {
@ -61,4 +69,25 @@ public class SharableManager {
}
});
}
private static void registerSharableEncryptDefinePane(Class<? extends Widget> mainClazz) {
String newClazzName = ClazzCreatorFactory.getInstance().createName(mainClazz);
Class<? extends Widget> newClazz;
try {
newClazz = (Class<? extends Widget>) Class.forName(newClazzName, false, mainClazz.getClassLoader());
} catch (Exception e) {
newClazz = (Class<? extends Widget>) ClazzCreatorFactory.getInstance().newSharableClazz(mainClazz.getClassLoader(), mainClazz);
}
if (FormWidgetDefinePaneFactoryBase.getDefinePane(newClazz) == null) {
FormWidgetDefinePaneFactoryBase.registerDefinePane(newClazz, FormWidgetDefinePaneFactoryBase.getDefinePane(mainClazz));
}
}
private static void registerSharableEncryptDefinePanes() {
registerSharableEncryptDefinePane(ElementCaseEditor.class);
registerSharableEncryptDefinePane(StableFactory.getMarkedClass(BridgeMark.CHART_EDITOR, AbstractBorderStyleWidget.class));
registerSharableEncryptDefinePane(WAbsoluteLayout.class);
registerSharableEncryptDefinePane(WCardMainBorderLayout.class);
}
}

17
designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java

@ -65,6 +65,8 @@ public class ShareGeneratePane extends BasicPane {
private static final Dimension DIALOG_SIZE = new Dimension(670, 760);
private static final Dimension DIALOG_NORMAL_SIZE = new Dimension(670, 610);
private static final Border DIALOG_BORDER = BorderFactory.createEmptyBorder(0, 6, 4, 6);
private static final double MAX_WIDTH = 500.0;
private static final double MAX_HEIGHT = 260.0;
private JPanel mainPane = null;
private ShareMainPane uploadPane = null;
@ -303,6 +305,7 @@ public class ShareGeneratePane extends BasicPane {
}
private DefaultSharableWidget transform(DefaultSharableWidget info) {
confineSize(info);
//先屏蔽
//if (shareWidget instanceof AbstractBorderStyleWidget) {
@ -327,4 +330,18 @@ public class ShareGeneratePane extends BasicPane {
}
private void confineSize(DefaultSharableWidget info) {
double width = info.getWidth();
double height = info.getHeight();
if (width > 0 && height > 0 && (width > MAX_WIDTH || height > MAX_HEIGHT)) {
double aspectRatio = width / height;
if (width / height > MAX_WIDTH / MAX_HEIGHT) {
info.setWidth((int) MAX_WIDTH);
info.setHeight((int) (MAX_WIDTH / aspectRatio));
} else {
info.setHeight((int) MAX_HEIGHT);
info.setWidth((int) (MAX_HEIGHT * aspectRatio));
}
}
}
}

11
designer-realize/src/main/java/com/fr/grid/Grid.java

@ -134,6 +134,9 @@ public class Grid extends BaseGridComponent {
private boolean needRequestFocus = true;
// 截取缩略图时需透明(不能用默认白色填充),否则会遮挡组件样式的背景,其余情况的绘制可以用白色等默认颜色填充
private boolean isTranslucent = false;
public Grid(int resolution) {
this.resolution = resolution;
// 能触发processEvent,不管是否给component增加listener
@ -1458,4 +1461,12 @@ public class Grid extends BaseGridComponent {
this.paginateLineShowType = paginateLineShowType;
this.getElementCasePane().repaint();
}
public boolean isTranslucent() {
return isTranslucent;
}
public void setTranslucent(boolean translucent) {
isTranslucent = translucent;
}
}

18
designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java

@ -408,11 +408,11 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
int currentWidth = currentRight - currentLeft;
int currentHeight = currentBottom - currentTop;
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
if (cursorType == Cursor.NW_RESIZE_CURSOR || cursorType == Cursor.NE_RESIZE_CURSOR || cursorType == Cursor.SE_RESIZE_CURSOR || cursorType == Cursor.SW_RESIZE_CURSOR) {
if (aspectRatio) {
if (aspectRatio && resizingBackupBounds != null) {
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
double currentDiagonal = Math.pow(currentWidth, 2) + Math.pow(currentHeight, 2);
double backupDiagonal = Math.pow(backupWidth, 2) + Math.pow(backupHeight, 2);
@ -452,7 +452,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
floatElement.setTopDistance(topDistance);
floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu));
if (aspectRatio) {
if (aspectRatio && resizingBackupBounds != null) {
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
currentWidth = backupWidth * currentHeight / backupHeight;
currentRight = currentLeft + currentWidth;
FU floatX1_fu = FU.valueOfPix(currentLeft, resolution);
@ -465,7 +468,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
floatElement.setLeftDistance(leftDistance);
floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu));
if (aspectRatio) {
if (aspectRatio && resizingBackupBounds != null) {
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
currentHeight = backupHeight * currentWidth / backupWidth;
currentBottom = currentTop + currentHeight;
FU floatY1_fu = FU.valueOfPix(currentTop, resolution);

6
designer-realize/src/main/java/com/fr/grid/GridUI.java

@ -1128,8 +1128,10 @@ public class GridUI extends ComponentUI {
double realWidth = gridSize.getWidth();// 宽度
double realHeight = gridSize.getHeight();// 高度
// 画背景
this.paintBackground(g2d, grid, elementCase, resolution);
if (!grid.isTranslucent()) {
// 画背景
this.paintBackground(g2d, grid, elementCase, resolution);
}
// 画Grid Line
this.paintGridLine(g2d, grid, elementCase, realWidth, realHeight, resolution);

Loading…
Cancel
Save