diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java index d0bc499a2..f1d2433db 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java @@ -158,7 +158,7 @@ public class ProcedureDataPane extends AbstractTableDataPane 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 imp this.storeProcedureWorkerListener = null; } - + private StoreProcedure updateBeanWithOutExecute() { String dbName = connectionTableProcedurePane.getSelectedDatabaseConnnectonName(); @@ -266,16 +266,16 @@ public class ProcedureDataPane extends AbstractTableDataPane imp return sp; } - + @Override public StoreProcedure updateBean() { - + final StoreProcedure sp = updateBeanWithOutExecute(); if (updateWorker != null) { updateWorker.cancel(true); } updateWorker = new SwingWorker() { - + @Override protected Void doInBackground() throws Exception { DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER); @@ -284,7 +284,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp sp.refreshDataModelListAndResultNames(dataModels); return null; } - + @Override public void done() { DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER); @@ -293,7 +293,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp fireDSChanged(); } }; - + updateWorker.execute(); return sp; } @@ -359,17 +359,20 @@ public class ProcedureDataPane extends AbstractTableDataPane 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); } } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java index 17fbf5788..08274fd71 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java +++ b/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); } diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index 87b7f2f25..6c3323600 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -731,6 +731,16 @@ public class MutilTempalteTabPane extends JComponent { } } + /** + * 后台关闭当前编辑模板 + */ + public void closeCurrentTpl(){ + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + this.setIsCloseCurrent(true); + this.closeFormat(jTemplate); + this.closeSpecifiedTemplate(jTemplate); + } + /** * 关闭模板 * @@ -765,8 +775,8 @@ public class MutilTempalteTabPane extends JComponent { // 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板; // selectIndex 没有变化,但是对应的模板已经变成了前一张模板 if (closeIconIndex == selectedIndex || isCloseCurrent) { - // 如果 closeIconIndex 是最后一个被渲染画出的,那么预览上一个,防止数组越界 - if (closeIconIndex >= maxPaintIndex) { + // 如果当前关闭的模板在最右侧,那么预览上一个,防止数组越界 + if (selectedIndex >= maxPaintIndex) { // selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true selectedIndex--; } diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index 0fc3ca728..f3c85f6fb 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -17,6 +17,7 @@ import com.fr.file.FILE; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; import com.fr.file.filetree.IOFileNodeFilter; +import com.fr.form.fit.web.editpreview.FileLockStateObservable; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; @@ -47,6 +48,8 @@ import java.util.Arrays; import java.util.Collection; import java.util.Enumeration; import java.util.Objects; +import java.util.Observable; +import java.util.Observer; import static javax.swing.JOptionPane.WARNING_MESSAGE; import static javax.swing.JOptionPane.YES_NO_OPTION; @@ -76,6 +79,13 @@ public class TemplateTreePane extends JPanel implements FileOperations { scrollPane.setBorder(null); contentPane.add(scrollPane, BorderLayout.CENTER); + FileLockStateObservable.getInstance().addObserver(new Observer() { + @Override + public void update(Observable o, Object arg) { + TemplateTreePane.this.refresh(); + } + }); + /* * Tree.MouseAdapter */ @@ -202,15 +212,13 @@ public class TemplateTreePane extends JPanel implements FileOperations { @Override public void openFile() { // 判断是否是远程设计的锁定文件 - if (!WorkContext.getCurrent().isLocal()) { - FileNode node = reportletsTree.getSelectedFileNode(); - if (node == null) { - return; - } - String lock = node.getLock(); - if (lock != null && !lock.equals(node.getUserID())) { - return; - } + FileNode node = reportletsTree.getSelectedFileNode(); + if (node == null) { + return; + } + String lock = node.getLock(); + if (lock != null && !lock.equals(node.getUserID())) { + return; } String reportPath = reportletsTree.getSelectedTemplatePath(); final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath); diff --git a/designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java b/designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java index c07a4efe0..76b5037ef 100644 --- a/designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java @@ -2,6 +2,7 @@ package com.fr.design.fun; import com.fr.design.mainframe.JTemplate; import com.fr.stable.Filter; +import com.fr.stable.StringUtils; import com.fr.stable.fun.mark.Mutable; import java.util.Map; @@ -62,5 +63,13 @@ public interface PreviewProvider extends Mutable, Filter { */ String getActionType(); + /** + * 下拉弹出菜单的提示 + * @return 弹出菜单的提示 + */ + default String tooltipForPopItem() { + return StringUtils.EMPTY; + } + } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java index 9d10da3a7..22f6cb246 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java @@ -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); diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java index f3771a0f9..a748fa320 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java @@ -67,7 +67,7 @@ public class EnvFileTree extends RefreshableJTree { String lock = node.getLock(); String name = node.getName(); if (treeNode.hasFullAuthority()) { - if (lock != null && !node.getUserID().equals(lock)) { + if (lock != null && !lock.equals(node.getUserID())) { name = name + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked", "(", ")"); } this.setIcon(FileTreeIcon.getIcon(node)); diff --git a/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java b/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java index adb0e4847..2703a2a2b 100644 --- a/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java +++ b/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java @@ -18,6 +18,9 @@ import java.util.Arrays; import java.util.List; public class ParameterArrayPane extends JListControlPane { + + private static final String DEFAULT_PARAMETER_NAME_PREFIX = "para"; + /** * Constructor. */ @@ -63,7 +66,7 @@ public class ParameterArrayPane extends JListControlPane { new NameableSelfCreator(Toolkit.i18nText("Fine-Design_Basic_Engine_Parameter_Name"), Parameter.class, ParameterPane.class) { public Parameter createNameable(UnrepeatedNameHelper helper) { // 返回参数设置面板. - return new Parameter(helper.createUnrepeatedName("p")); + return new Parameter(helper.createUnrepeatedName(DEFAULT_PARAMETER_NAME_PREFIX)); } @Override diff --git a/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java b/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java index 045d54413..c8fe8e8ad 100644 --- a/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java +++ b/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java @@ -87,23 +87,27 @@ public class VersionCheckUtils { public static void showVersionCheckDialog(String envName) { if (!VersionCheckUtils.versionCheck(envName)) { - NotificationDialog notificationDialog = new NotificationDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Sync_Prompt"), - false, NotificationDialog.WARNING_MESSAGE, Toolkit.i18nText("Fine-Design_Basic_Sync_Check_Brief_Info"), new NotificationDialogAction() { - @Override - public String name() { - return "VERSION_CHECK"; - } - - @Override - public void doClick() { - CheckServiceDialog checkServiceDialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), GeneralUtils.readFullBuildNO(), getRemoteBranch(envName),getNoExistServiceDescription(envName)); - checkServiceDialog.setVisible(true); - } - }); - notificationDialog.setVisible(true); + showNotificationDialog(envName); } } + private static void showNotificationDialog(String envName) { + NotificationDialog notificationDialog = new NotificationDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Sync_Prompt"), + false, NotificationDialog.WARNING_MESSAGE, Toolkit.i18nText("Fine-Design_Basic_Sync_Check_Brief_Info"), new NotificationDialogAction() { + @Override + public String name() { + return "VERSION_CHECK"; + } + + @Override + public void doClick() { + CheckServiceDialog checkServiceDialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), GeneralUtils.readFullBuildNO(), getRemoteBranch(envName), getNoExistServiceDescription(envName)); + checkServiceDialog.setVisible(true); + } + }); + notificationDialog.setVisible(true); + } + public static boolean checkLocalAndRemoteJartime(String envName) { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); diff --git a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java index 441a1fdec..26cd7da73 100644 --- a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java +++ b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java @@ -167,13 +167,15 @@ public class CheckServiceDialog extends JDialog implements ActionListener { centerPanel.add(detailsPane, BorderLayout.CENTER); JPanel buttonPanel = FRGUIPaneFactory.createBorderLayout_M_Pane(); buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); - boolean Sync = false; - if (isOnline() && Sync) { + if (isOnline()) { ignoreButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Sync_Ignore")); 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); + if(jarConsistency && differentPlugins.isEmpty()){ + syncButton.setEnabled(false); + } progressBar = new JProgressBar(); progressBar.setUI(new MotifProgressBarUI()); progressBar.setForeground(UpdateConstants.BAR_COLOR); @@ -184,6 +186,8 @@ 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); UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Button_Confirm")); okButton.addActionListener(this); buttonPanel.add(okButton, BorderLayout.EAST); @@ -307,79 +311,84 @@ public class CheckServiceDialog extends JDialog implements ActionListener { private MouseListener syncButtonClickListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - ignoreButton.setEnabled(false); - syncButton.setEnabled(false); - String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")}; - if (!jarConsistency) { - int a = FineJOptionPane.showOptionDialog(getParent(), Toolkit.i18nText("Fine-Design_Basic_Sync_Info_Information"), - Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, QUESTION_MESSAGE, IOUtils.readIcon("com/fr/design/icon/versioncheck/question.png"), option, 1); - if (0 == a) { - progressBar.setVisible(true); - progressBar.setString(Toolkit.i18nText("Fine-Design_Update_Info_Wait_Message")); - syncButton.setEnabled(false); - deletePreviousPropertyFile(); - final String installLib = StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LOGS_NAME, UpdateConstants.INSTALL_LIB); - final JFrame frame = DesignerContext.getDesignerFrame(); - final RestartHelper helper = new RestartHelper(); - FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY); - SyncFailedPluginsDialog syncFailedPluginsDialog = new SyncFailedPluginsDialog(frame, JSONArray.create()); - new SyncFileProcess(progressBar, remoteBuildNo, syncFailedPluginsDialog) { - @Override - public void onDownloadSuccess() { - deleteForDesignerUpdate(installLib); - progressBar.setVisible(false); - syncFailedPluginsDialog.showDialog(); - if (!syncFailedPluginsDialog.restartClicked()) { - helper.restartForUpdate(frame); - } - } + sync(); + } + }; - @Override - public void onDownloadFailed() { - progressBar.setVisible(false); - deleteForDesignerUpdate(installLib); - ErrorDialog errorDialog = new ErrorDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Sync_Fail")); - errorDialog.setVisible(true); + private void sync() { + ignoreButton.setEnabled(false); + syncButton.setEnabled(false); + String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")}; + if (!jarConsistency) { + int a = FineJOptionPane.showOptionDialog(getParent(), Toolkit.i18nText("Fine-Design_Basic_Sync_Info_Information"), + Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, QUESTION_MESSAGE, IOUtils.readIcon("com/fr/design/icon/versioncheck/question.png"), option, 1); + if (0 == a) { + progressBar.setVisible(true); + progressBar.setString(Toolkit.i18nText("Fine-Design_Update_Info_Wait_Message")); + syncButton.setEnabled(false); + deletePreviousPropertyFile(); + final String installLib = StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LOGS_NAME, UpdateConstants.INSTALL_LIB); + final JFrame frame = DesignerContext.getDesignerFrame(); + final RestartHelper helper = new RestartHelper(); + FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY); + SyncFailedPluginsDialog syncFailedPluginsDialog = new SyncFailedPluginsDialog(frame, JSONArray.create()); + new SyncFileProcess(progressBar, remoteBuildNo, syncFailedPluginsDialog) { + @Override + public void onDownloadSuccess() { + deleteForDesignerUpdate(installLib); + progressBar.setVisible(false); + syncFailedPluginsDialog.showDialog(); + if (!syncFailedPluginsDialog.restartClicked()) { helper.restartForUpdate(frame); } - }.execute(); - } - } else { - //到这边说明主jar是一致的,就只尝试同步插件 - new SwingWorker() { - - @Override - protected JSONArray doInBackground() { - progressBar.setVisible(true); - progressBar.setString(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugins")); - progressBar.setValue(0); - return VersionCheckUtils.syncPlugins(differentPlugins); } @Override - protected void done() { + public void onDownloadFailed() { progressBar.setVisible(false); - JSONArray syncFailedPlugins = null; - try { - syncFailedPlugins = get(); - } catch (Exception ex) { - FineLoggerFactory.getLogger().error(ex.getMessage(), ex); - } - if (syncFailedPlugins != null && syncFailedPlugins.size() > 0) { - SyncFailedPluginsDialog syncFailedPluginsDialog = new SyncFailedPluginsDialog(DesignerContext.getDesignerFrame(), syncFailedPlugins); - syncFailedPluginsDialog.setVisible(true); - } else { - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Basic_Sync_Success"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), - FineJOptionPane.INFORMATION_MESSAGE); - } - close(); + deleteForDesignerUpdate(installLib); + ErrorDialog errorDialog = new ErrorDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Sync_Fail")); + errorDialog.setVisible(true); + helper.restartForUpdate(frame); } }.execute(); } + } else { + //到这边说明主jar是一致的,就只尝试同步插件 + new SwingWorker() { + + @Override + protected JSONArray doInBackground() { + progressBar.setVisible(true); + progressBar.setString(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugins")); + progressBar.setValue(0); + return VersionCheckUtils.syncPlugins(differentPlugins); + } + + @Override + protected void done() { + progressBar.setVisible(false); + JSONArray syncFailedPlugins = null; + try { + syncFailedPlugins = get(); + } catch (Exception ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + if (syncFailedPlugins != null && syncFailedPlugins.size() > 0) { + SyncFailedPluginsDialog syncFailedPluginsDialog = new SyncFailedPluginsDialog(DesignerContext.getDesignerFrame(), syncFailedPlugins); + syncFailedPluginsDialog.setVisible(true); + } else { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Sync_Success"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + FineJOptionPane.INFORMATION_MESSAGE); + } + close(); + } + }.execute(); } - }; + } + private boolean deletePreviousPropertyFile() { File moveFile = new File(RestartHelper.MOVE_FILE); diff --git a/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_e.png b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_e.png new file mode 100644 index 000000000..650567ee9 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_e.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_n.png b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_n.png new file mode 100644 index 000000000..1085265c0 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_n.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_ne.png b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_ne.png new file mode 100644 index 000000000..8f8163a6f Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_ne.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_nw.png b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_nw.png new file mode 100644 index 000000000..af33c873d Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_nw.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_s.png b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_s.png new file mode 100644 index 000000000..1085265c0 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_s.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_se.png b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_se.png new file mode 100644 index 000000000..af33c873d Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_se.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_sw.png b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_sw.png new file mode 100644 index 000000000..8f8163a6f Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_sw.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_w.png b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_w.png new file mode 100644 index 000000000..650567ee9 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_w.png differ diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index 22698ef5b..523533e5e 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/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; + /** * 构造函数 */ @@ -351,15 +353,18 @@ public class XWCardMainBorderLayout extends XWBorderLayout { @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); - } } /** @@ -464,4 +469,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout { return LARGEPREFERREDSIZE; } + public void setShowOuterShadowBorder(boolean showOuterShadowBorder) { + this.showOuterShadowBorder = showOuterShadowBorder; + } } diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java index 6c19c9a63..324213bc3 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java @@ -20,7 +20,6 @@ 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; @@ -38,15 +37,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; @@ -434,13 +446,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 +490,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 +526,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); + } - hintField.setBounds((int) (centerX - width / 2.0), (int) (centerY - height / 2.0), (int) width, (int) height); + 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)); + + 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 +642,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 +668,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 +688,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 +732,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 +757,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 +767,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 +777,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 +787,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() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java index 37094494b..25bf1f5de 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java @@ -5,6 +5,7 @@ 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.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; @@ -453,6 +454,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); + } + } + } + }); + } /** diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index b46fffdfb..50108b995 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -34,6 +34,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; @@ -613,6 +614,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; @@ -661,13 +663,36 @@ public class EditingMouseListener extends MouseInputAdapter { } private boolean responseTabLayout(XCreator creator, MouseEvent e) { - if (creator.acceptType(XWCardMainBorderLayout.class) ) { - creator.respondClick(this, e); + LinkedList 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; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index c48c88101..a8ddce03c 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -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; } /** diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java index 7d3711a69..c25d99b1a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java @@ -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 selection; private Rectangle backupBounds; private ArrayList recs = new ArrayList(); + // 选中的组件外层嵌套的tab块 head->tail 由内向外 + private LinkedList tabList = new LinkedList<>(); public FormSelection() { selection = new ArrayList(); @@ -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 getTabList() { + return tabList; + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index bc32c5fd9..891ba8893 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -827,6 +827,9 @@ public class JForm extends JTemplate implements BaseJForm { public void initComponent() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel inbuiltDefineContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.add(inbuiltDefineContentPane, BorderLayout.NORTH); + designerWidth = new UIBoundSpinner(1, Integer.MAX_VALUE, 1); - JPanel advancePane = createAdvancePane(); - UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane); - this.add(advanceExpandablePane, BorderLayout.NORTH); JPanel layoutPane = createBoundsPane(); UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Size"), 280, 20, layoutPane); - this.add(layoutExpandablePane, BorderLayout.CENTER); + inbuiltDefineContentPane.add(layoutExpandablePane, BorderLayout.NORTH); + + JPanel advancePane = createAdvancePane(); + UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane); + inbuiltDefineContentPane.add(advanceExpandablePane, BorderLayout.CENTER); + this.addExtraUIExpandablePaneFromPlugin(); } @@ -83,7 +88,7 @@ public class RootDesignDefinePane extends AbstractDataModify { panel.add(uiExpandablePane); } } - this.add(panel, BorderLayout.SOUTH); + this.add(panel, BorderLayout.CENTER); } public JPanel createBoundsPane() { diff --git a/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java b/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java index 7db99129c..908defcbb 100644 --- a/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java +++ b/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java @@ -1,7 +1,9 @@ package com.fr.design.preview; import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.fun.impl.AbstractPreviewProvider; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JTemplate; import com.fr.general.web.ParameterConstants; @@ -17,7 +19,7 @@ public class DeveloperPreview extends AbstractPreviewProvider { @Override public String nameForPopupItem() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Developer_Preview"); + return Toolkit.i18nText("Fine-Designer_Fit_Developer_Preview"); } @Override @@ -35,11 +37,21 @@ public class DeveloperPreview extends AbstractPreviewProvider { return PREVIEW_TYPE; } + public String tooltipForPopItem() { + return Toolkit.i18nText("Fine-Designer_Fit_Developer_Preview_Menu_Hint"); + } + + @Override + public void onClick(JTemplate jt) { + MutilTempalteTabPane.getInstance().closeCurrentTpl(); + super.onClick(jt); + } + @Override public Map parametersForPreview() { Map map = new HashMap(); - map.put(ParameterConstants.OP, "developer_preview"); + map.put(ParameterConstants.OP, "editable_preview"); return map; } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/UIBoundSpinner.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/UIBoundSpinner.java index 426d27f1a..ea90f3f39 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/UIBoundSpinner.java +++ b/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); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java index cabe9bb17..42f46039d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java @@ -31,6 +31,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; @@ -142,7 +143,10 @@ public class FormElementCaseDesigner g.translate(-elementCasePane.getGridCorner().getWidth(), -elementCasePane.getGridCorner().getHeight()); } - this.elementCasePane.paintComponents(g); + Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null; + if (grid != null) { + grid.paintAll(g); + } } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); diff --git a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java index 93f07b260..99d6c556b 100644 --- a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java +++ b/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)); + } + } + } }