diff --git a/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java b/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java index 84fd684ae8..24dd314844 100644 --- a/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java +++ b/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java @@ -7,8 +7,11 @@ import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplateProvider; +import com.fr.form.ui.DataControl; +import com.fr.form.ui.MultiFileEditor; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; +import com.fr.stable.StringUtils; import com.fr.stable.js.WidgetName; import java.util.Iterator; @@ -214,6 +217,17 @@ public abstract class DesignModelAdapter getWidgetsName(); + /** + * 判断是否是值编辑器可以设置的控件类型 + * @param widget 控件 + * @return 可以设置返回true,否则返回false + */ + public boolean widgetAccepted(Widget widget) { + return widget != null + && StringUtils.isNotEmpty(widget.getWidgetName()) + && (widget instanceof DataControl || widget instanceof MultiFileEditor); + } + /** * 更新缓存的参数 */ diff --git a/designer-base/src/main/java/com/fr/design/RestartHelper.java b/designer-base/src/main/java/com/fr/design/RestartHelper.java index 5720629e79..cdb4fc532e 100644 --- a/designer-base/src/main/java/com/fr/design/RestartHelper.java +++ b/designer-base/src/main/java/com/fr/design/RestartHelper.java @@ -1,7 +1,7 @@ package com.fr.design; -import com.fr.design.os.impl.RestartAction; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.os.impl.RestartAction; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.log.FineLoggerFactory; @@ -9,7 +9,9 @@ import com.fr.stable.ArrayUtils; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.os.support.OSBasedAction; -import com.fr.stable.os.support.OSSupportCenter; +import com.fr.workspace.WorkContext; + +import javax.swing.*; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -29,7 +31,8 @@ public class RestartHelper { public static final String RECORD_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "delete.properties"); public static final String MOVE_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "move.properties"); - private static OSBasedAction restartAction; + private static final OSBasedAction restartAction = new RestartAction(); + /** * 把要删除的文件都记录到delete.properties中 * @@ -141,6 +144,20 @@ public class RestartHelper { restart(ArrayUtils.EMPTY_STRING_ARRAY); } + public static void restartForUpdate(JFrame frame) { + try { + restartAction.execute(ArrayUtils.EMPTY_STRING_ARRAY); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage()); + } finally { + WorkContext.getCurrent().close(); + frame.dispose(); + System.exit(0); + } + } + + + /** * 重启设计器并删除某些特定的文件 * @@ -169,7 +186,7 @@ public class RestartHelper { restartAction.execute(filesToBeDelete); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); - }finally { + } finally { try { if (null != randomAccessFile) { randomAccessFile.close(); @@ -179,12 +196,5 @@ public class RestartHelper { } DesignerContext.getDesignerFrame().exit(); } - - } - /** - * 提前初始化重启动作 - */ - public static void initRestartAction(){ - restartAction = OSSupportCenter.getAction(RestartAction.class); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 4c2bd04404..4a1c208c91 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -1,6 +1,7 @@ package com.fr.design.actions.file; import com.fr.cluster.ClusterBridge; +import com.fr.cluster.engine.base.FineClusterConfig; import com.fr.config.Configuration; import com.fr.config.ServerPreferenceConfig; import com.fr.design.DesignerEnvManager; @@ -46,36 +47,10 @@ import com.fr.workspace.WorkContext; import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.git.config.GcConfig; -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; -import javax.swing.JDialog; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JProgressBar; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import javax.swing.SwingWorker; -import javax.swing.Timer; -import javax.swing.UIManager; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dialog; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.Window; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; +import javax.swing.*; +import javax.swing.event.*; +import java.awt.*; +import java.awt.event.*; import java.io.File; import java.text.DecimalFormat; import java.util.Locale; @@ -87,7 +62,7 @@ import static com.fr.design.i18n.Toolkit.i18nText; /** * 选项对话框 * - * @author zhou + * @editor zhou * @since 2012-3-28下午3:39:48 */ public class PreferencePane extends BasicPane { @@ -159,7 +134,6 @@ public class PreferencePane extends BasicPane { private IntegerEditor portEditor; private UICheckBox oracleSpace; private UISpinner cachingTemplateSpinner; - private UICheckBox openDebugComboBox; private UICheckBox useOptimizedUPMCheckbox; private UICheckBox useUniverseDBMCheckbox; private UICheckBox joinProductImproveCheckBox; @@ -170,12 +144,10 @@ public class PreferencePane extends BasicPane { private UICheckBox saveCommitCheckBox; private UICheckBox useIntervalCheckBox; private IntegerEditor saveIntervalEditor; - private UICheckBox gcEnableCheckBox; private UIButton gcButton; private UILabel remindVcsLabel; - private JDialog gcDialog; private UILabel gcMessage = new UILabel(); private JPanel gcDialogDownPane = new JPanel(); @@ -222,12 +194,6 @@ public class PreferencePane extends BasicPane { oracleSpace = new UICheckBox(i18nText("Fine-Design_Basic_Show_All_Oracle_Tables")); oraclePane.add(oracleSpace); - - JPanel debuggerPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Develop_Tools")); - openDebugComboBox = new UICheckBox(i18nText("Fine-Design_Basic_Open_Debug_Window")); - debuggerPane.add(openDebugComboBox, BorderLayout.CENTER); - advancePane.add(debuggerPane); - JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Update_Plugin_Manager")); useOptimizedUPMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager")); upmSelectorPane.add(useOptimizedUPMCheckbox); @@ -242,12 +208,16 @@ public class PreferencePane extends BasicPane { joinProductImproveCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Join_Product_Improve")); improvePane.add(joinProductImproveCheckBox); - if (SupportOSImpl.AUTOPUSHUPDATE.support()) { + if(SupportOSImpl.AUTOPUSHUPDATE.support()){ autoPushUpdateCheckBox = new UICheckBox(i18nText("Fine-Design_Automatic_Push_Update")); - - improvePane.add(autoPushUpdateCheckBox); } + /* + if (DesignerPushUpdateManager.getInstance().isAutoPushUpdateSupported()) { + autoPushUpdateCheckBox = new UICheckBox(i18nText("Fine-Design_Automatic_Push_Update")); + improvePane.add(autoPushUpdateCheckBox); + }*/ + JPanel spaceUpPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); spaceUpPane.add(oraclePane, BorderLayout.NORTH); spaceUpPane.add(createMemoryPane(), BorderLayout.CENTER); @@ -264,9 +234,7 @@ public class PreferencePane extends BasicPane { private void createVcsSettingPane(JPanel generalPane) { JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Title")); generalPane.add(vcsPane); - remindVcsLabel = new UILabel(i18nText("Fine-Design_Vcs_Remind")); - remindVcsLabel.setVisible(!VcsHelper.getInstance().needInit()); vcsEnableCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_SaveAuto")); saveCommitCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_No_Delete")); @@ -290,7 +258,7 @@ public class PreferencePane extends BasicPane { @Override public void stateChanged(ChangeEvent e) { boolean selected = vcsEnableCheckBox.isSelected(); - if (selected) { + if (selected && vcsEnableCheckBox.isEnabled()) { saveCommitCheckBox.setEnabled(true); saveIntervalEditor.setEnabled(true); useIntervalCheckBox.setEnabled(true); @@ -334,14 +302,9 @@ public class PreferencePane extends BasicPane { gcEnableCheckBox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - gcButton.setEnabled(gcEnableCheckBox.isSelected()); + gcButton.setEnabled(gcEnableCheckBox.isSelected() && gcEnableCheckBox.isEnabled()); } }); - //集群下禁用 - if (ClusterBridge.isClusterMode()) { - gcEnableCheckBox.setEnabled(false); - gcButton.setEnabled(false); - } return gcControlPane; } @@ -523,8 +486,23 @@ public class PreferencePane extends BasicPane { JPanel logLevelPane = FRGUIPaneFactory.createTitledBorderPane("log" + i18nText("Fine-Design_Basic_Level_Setting")); logPane.add(logLevelPane); logLevelComboBox = new UIComboBox(LOG); - logLevelComboBox.setEnabled(WorkContext.getCurrent().isLocal()); logLevelPane.add(logLevelComboBox); + logLevelComboBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Configurations.update(new Worker() { + @Override + public void run() { + Log4jConfig.getInstance().setRootLevel((Level) logLevelComboBox.getSelectedItem()); + } + + @Override + public Class[] targets() { + return new Class[]{Log4jConfig.class}; + } + }); + } + }); } private void createLanPane(JPanel generalPane) { @@ -552,8 +530,8 @@ public class PreferencePane extends BasicPane { }); UILabel noticeLabel = new UILabel(i18nText("Fine-Design_Basic_Work_After_Restart_Designer"));//sail:提示重启后生效 double p = TableLayout.PREFERRED; - double[] rowSize = {p}; - double[] columnSize = {p, p, p}; + double rowSize[] = {p}; + double columnSize[] = {p, p, p}; Component[][] components = { {languageLabel, languageComboBox, noticeLabel}, }; @@ -593,7 +571,7 @@ public class PreferencePane extends BasicPane { private void createLengthPane(JPanel advancePane) { double p = TableLayout.PREFERRED; - double[] rowSize = {p}; + double rowSize[] = {p}; // 长度单位选择 JPanel lengthPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Setting_Ruler_Units")); @@ -615,8 +593,8 @@ public class PreferencePane extends BasicPane { private void createServerPane(JPanel advancePane) { double p = TableLayout.PREFERRED; - double[] rowSize = {p}; - double[] columnSize = {p, p, p}; + double rowSize[] = {p}; + double columnSize[] = {p, p, p}; JPanel serverPortPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Web_Preview_Port_Setting")); advancePane.add(serverPortPane); @@ -655,7 +633,7 @@ public class PreferencePane extends BasicPane { /** * The method of populate. * - * @param designerEnvManager 设计器环境管理器 + * @param designerEnvManager */ public void populate(DesignerEnvManager designerEnvManager) { if (designerEnvManager == null) { @@ -684,6 +662,11 @@ public class PreferencePane extends BasicPane { defaultStringToFormulaBox.setSelected(false); } VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager(); + if (FineClusterConfig.getInstance().isCluster()) { + vcsEnableCheckBox.setEnabled(false); + gcEnableCheckBox.setEnabled(false); + } + if (VcsHelper.getInstance().needInit()) { vcsEnableCheckBox.setSelected(vcsConfigManager.isVcsEnable()); } else { @@ -717,9 +700,8 @@ public class PreferencePane extends BasicPane { this.pageLengthComboBox.setSelectedIndex(designerEnvManager.getPageLengthUnit()); this.reportLengthComboBox.setSelectedIndex(designerEnvManager.getReportLengthUnit()); - this.portEditor.setValue(designerEnvManager.getEmbedServerPort()); + this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort())); - openDebugComboBox.setSelected(designerEnvManager.isOpenDebug()); useOptimizedUPMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseOptimizedUPM()); useUniverseDBMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseUniverseDBM()); @@ -787,9 +769,7 @@ public class PreferencePane extends BasicPane { designerEnvManager.setPageLengthUnit((short) pageLengthComboBox.getSelectedIndex()); designerEnvManager.setReportLengthUnit((short) reportLengthComboBox.getSelectedIndex()); - designerEnvManager.setJettyServerPort(portEditor.getValue()); - - designerEnvManager.setOpenDebug(openDebugComboBox.isSelected()); + designerEnvManager.setJettyServerPort(portEditor.getValue().intValue()); designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected()); designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue()); @@ -821,24 +801,17 @@ public class PreferencePane extends BasicPane { designerEnvManager.setUndoLimit(MAX_UNDO_LIMIT_50); } - if (WorkContext.getCurrent().isLocal()) { - Configurations.update(new Worker() { - @Override - public void run() { - Level level = (Level) logLevelComboBox.getSelectedItem(); - if (level != null) { - Log4jConfig.getInstance().setRootLevel(level); - } - } + Configurations.update(new Worker() { + @Override + public void run() { + Log4jConfig.getInstance().setRootLevel(((Level) logLevelComboBox.getSelectedItem())); + } - @Override - public Class[] targets() { - @SuppressWarnings("unchecked") - Class[] classes = new Class[]{Log4jConfig.class}; - return classes; - } - }); - } + @Override + public Class[] targets() { + return new Class[]{Log4jConfig.class}; + } + }); Configurations.update(new Worker() { @Override @@ -910,7 +883,7 @@ public class PreferencePane extends BasicPane { } catch (InterruptedException e) { FineLoggerFactory.getLogger().error(e, e.getMessage()); } - updateGcDialogPanelInfo(i18nText("Fine-Design_Vcs_Reduce_File_Size") + fileSizeConvert(size)); + updateGcDialogPanelInfo(size <= 0 ? i18nText("Fine-Design_Vcs_No_Optimizable_File") : i18nText("Fine-Design_Vcs_Reduce_File_Size") + fileSizeConvert(size)); gcDialogDownPane.revalidate(); gcDialogDownPane.repaint(); gcDialogDownPane.add(gcOkButton); @@ -1089,3 +1062,4 @@ public class PreferencePane extends BasicPane { } } + diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index f1e911e7a8..0018d5333b 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -38,6 +38,7 @@ import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; +import javax.swing.JFrame; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.io.ByteArrayOutputStream; @@ -422,7 +423,7 @@ public abstract class DesignTableDataManager { final Map parameterMap = new HashMap<>(); if (needInputParams(isMustInputParameters, parameters)) { final ParameterInputPane pPane = new ParameterInputPane(parameters); - pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + pPane.showSmallWindow(new JFrame(), new DialogActionAdapter() { @Override public void doOk() { parameterMap.putAll(pPane.update()); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java index 413a0f00d1..028f71363b 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java @@ -438,6 +438,8 @@ public class ChoosePane extends BasicBeanPane implements Refresha } } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Failed"), JOptionPane.ERROR_MESSAGE); } } @@ -461,7 +463,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha if (!connect) { DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); JOptionPane.showMessageDialog(designerFrame, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Failed"), JOptionPane.INFORMATION_MESSAGE); + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Failed"), JOptionPane.ERROR_MESSAGE); failedToFindTable(); return null; } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java index d6137b986e..7bbcda825f 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java @@ -43,7 +43,8 @@ public class JDBCDefPane extends JPanel { jdbcMap.put(OTHER_DB, new DriverURLName[]{new DriverURLName("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:"), new DriverURLName("org.hsqldb.jdbcDriver", "jdbc:hsqldb:file:[PATH_TO_DB_FILES]"), new DriverURLName("com.inet.tds.TdsDriver", "jdbc:inetdae7:localhost:1433/"), new DriverURLName("COM.cloudscape.JDBCDriver", "jdbc:cloudscape:/cloudscape/"), - new DriverURLName("com.internetcds.jdbc.tds.Driver", "jdbc:freetds:sqlserver://localhost/")}); + new DriverURLName("com.internetcds.jdbc.tds.Driver", "jdbc:freetds:sqlserver://localhost/"), + new DriverURLName("com.fr.swift.jdbc.Driver", "jdbc:swift:emb://default")}); jdbcMap.put("Inceptor",new DriverURLName[]{new DriverURLName("org.apache.hive.jdbc.HiveDriver","jdbc:inceptor2://localhost:10000/default"), new DriverURLName("org.apache.hadoop.hive.jdbc.HiveDriver","jdbc:inceptor://localhost:10000/default")}); jdbcMap.put("Oracle", new DriverURLName[]{new DriverURLName("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@localhost:1521:databaseName")}); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java index 383a1f02aa..01d7c9a6ff 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java @@ -27,15 +27,7 @@ import com.fr.function.TIME; import com.fr.general.FRFont; import com.fr.log.FineLoggerFactory; -import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.SwingWorker; -import javax.swing.UIManager; +import javax.swing.*; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableModel; @@ -163,7 +155,7 @@ public class PreviewTablePane extends BasicPane { this.add(new JScrollPane(preveiwTable), BorderLayout.CENTER); if (this.dialog == null) { - this.dialog = this.showWindow(DesignerContext.getDesignerFrame()); + this.dialog = this.showWindow(new JFrame()); } progressBar = new AutoProgressBar(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) { public void doMonitorCanceled() { diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java index 215ba7588f..f55195d3b3 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java @@ -442,7 +442,7 @@ public class FileTableDataPane extends AbstractTableDataPane { @Override public void actionPerformed(ActionEvent e) { FILEChooserPane fileChooser = FILEChooserPane.getInstance(true, false, new ChooseFileFilter(getFileSuffix())); - if (fileChooser.showOpenDialog(DesignerContext.getDesignerFrame()) == FILEChooserPane.OK_OPTION) { + if (fileChooser.showOpenDialog(FileTableDataPane.this) == FILEChooserPane.OK_OPTION) { final FILE file = fileChooser.getSelectedFILE(); if (file == null) {// 选择的文件不能是 null return; diff --git a/designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java b/designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java index 2a1c0cc94e..a1082b62f9 100644 --- a/designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java +++ b/designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java @@ -13,6 +13,7 @@ import com.fr.workspace.WorkContext; import com.fr.workspace.server.authority.AuthorityOperator; import com.fr.workspace.server.authority.decision.DecisionOperator; +import java.lang.reflect.UndeclaredThrowableException; import java.util.ArrayList; public class NodeAuthProcessor { @@ -41,9 +42,15 @@ public class NodeAuthProcessor { if (!WorkContext.getCurrent().isLocal()) { try { String userName = WorkContext.getCurrent().getConnection().getUserName(); - String userId = WorkContext.getCurrent().get(DecisionOperator.class).getUserIdByName(userName); + DesignAuthority[] authorities = null; + try { + String userId = WorkContext.getCurrent().get(DecisionOperator.class).getUserIdByName(userName); + authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities(userId); + } catch(UndeclaredThrowableException e) { + // 兼容旧版本的服务器 + authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities(); + } // 远程设计获取设计成员的权限列表 - DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities(userId); DesignAuthority authority = null; if (authorities != null) { diff --git a/designer-base/src/main/java/com/fr/design/fun/ParameterWidgetOptionProvider.java b/designer-base/src/main/java/com/fr/design/fun/ParameterWidgetOptionProvider.java index 685c81a921..ffcfef58bc 100644 --- a/designer-base/src/main/java/com/fr/design/fun/ParameterWidgetOptionProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/ParameterWidgetOptionProvider.java @@ -17,6 +17,7 @@ public interface ParameterWidgetOptionProvider extends Mutable { /** * 自定义参数控件的实际类,该类需要继承自com.fr.form.ui.Widget + * 如果有控件值属性,该类需要实现DataControl接口,否则可能有部分功能无法使用,比如:值编辑器选择控件的时候无法找到插件里的控件 * @return 控件类 */ Class classForWidget(); diff --git a/designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java b/designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java new file mode 100644 index 0000000000..4f4ea45c3c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java @@ -0,0 +1,40 @@ +package com.fr.design.fun; + +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILEChooserPane; +import com.fr.stable.fun.mark.Mutable; + +import javax.swing.Icon; + +/** + * Created by kerry on 2019-10-11 + */ +public interface ReportSupportedFileUIProvider extends Mutable { + + int CURRENT_LEVEL = 1; + + String XML_TAG = "ReportSupportedFileUIProvider"; + + /** + * 向文件选择器中添加指定文件类型过滤器 + * @param fileChooser 文件选择器 + * @param suffix 文件后缀 + */ + void addChooseFileFilter(FILEChooserPane fileChooser, String suffix); + + + /** + * 获取文件关联的icon + * @param path 文件路径 + * @param isShowLock 是否显示被锁住 + * @return 对应的图标 + */ + Icon getFileIcon(String path,boolean isShowLock); + + /** + * 保存为新类型文件 + * @param targetPath 目标路径 + * @param jTemplate 模板对象 + */ + boolean saveToNewFile(String targetPath, JTemplate jTemplate); +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java new file mode 100644 index 0000000000..e8d1dfcc19 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java @@ -0,0 +1,40 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.ReportSupportedFileUIProvider; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILEChooserPane; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +import javax.swing.Icon; + +/** + * Created by kerry on 2019-10-14 + */ +@API(level = ReportSupportedFileUIProvider.CURRENT_LEVEL) +public abstract class AbstractReportSupportedFileUIProvider extends AbstractProvider implements ReportSupportedFileUIProvider { + @Override + public void addChooseFileFilter(FILEChooserPane fileChooser, String suffix) { + + } + + @Override + public Icon getFileIcon(String path, boolean isShowLock) { + return null; + } + + @Override + public boolean saveToNewFile(String targetPath, JTemplate jTemplate) { + return false; + } + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/RegPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/RegPane.java index 2df45f8923..f84d0f5fdb 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/RegPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/RegPane.java @@ -111,8 +111,8 @@ public class RegPane extends BasicPane { cardPane.setPreferredSize(new Dimension(0,0 )); detailedCardLayout.show(cardPane, "Default"); } - fireRegChangeAction(); } + fireRegChangeAction(); } }); } diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java index 1ffb3c1dde..12b894ddce 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java @@ -35,6 +35,7 @@ public class UINumberField extends UITextField { private double maxValue = Double.MAX_VALUE; private boolean isContentChanged = false; + private boolean fillNegativeNumber = true; public UINumberField() { this(MAX_INTEGERLENGTH_32, MAX_DECIMALLENGTH); @@ -62,6 +63,10 @@ public class UINumberField extends UITextField { initListener(); } + public void canFillNegativeNumber(boolean fillNegativeNumber) { + this.fillNegativeNumber = fillNegativeNumber; + } + public int getMaxIntegerLength() { return maxIntegerLength; } @@ -185,6 +190,9 @@ public class UINumberField extends UITextField { // kunsnat: 这种限制输入 有个不好的地方, 比如删除时: 10.1 最大值限定100, 那么就删除中间的小数点之后变为101, 超出了100. // 但是直接限制不能删除中间类似小数点, 那么也可能遇到: 最小值10 , 从100变化到其中的19, 就很难.. private boolean notChange(String strNew) { + if (!fillNegativeNumber && strNew.contains("-")) { + return true; + } boolean noChange = false; boolean isMinus = strNew.startsWith("-"); strNew = strNew.replaceFirst("-", StringUtils.EMPTY); // 控制能输入负数 diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java index 8c5f0e154a..f5da5302c4 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java @@ -1,14 +1,15 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.FRContext; -import com.fr.design.ExtraDesignClassManager; -import com.fr.design.mainframe.App; +import com.fr.base.extension.FileExtension; import com.fr.general.GeneralContext; import com.fr.plugin.context.PluginContext; import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; +import com.fr.report.ExtraReportClassManager; +import com.fr.report.fun.ReportSupportedFileProvider; import java.util.ArrayList; import java.util.Arrays; @@ -44,10 +45,10 @@ public class FileNodeConstants { }); } - private static void addAppExtensions(String[] extensions) { + private static void addAppExtensions(FileExtension[] extensions) { for (int i = 0, size = extensions.length; i < size; i++) { - if (!supportFileType.contains(extensions[i])) { - supportFileType.add(extensions[i]); + if (!supportFileType.contains(extensions[i].getExtension())) { + supportFileType.add(extensions[i].getExtension()); } } } @@ -55,12 +56,14 @@ public class FileNodeConstants { private static void initSupportedTypes() { try { rwl.writeLock().lock(); - supportFileType = new ArrayList<>(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); + supportFileType = new ArrayList(); //通过插件扩展的 - Set apps = ExtraDesignClassManager.getInstance().getArray(App.MARK_STRING); - for (App app : apps) { - addAppExtensions(app.defaultExtensions()); + Set providers = ExtraReportClassManager.getInstance().getArray(ReportSupportedFileProvider.XML_TAG); + for (ReportSupportedFileProvider provider : providers) { + addAppExtensions(provider.getFileExtensions()); } + supportFileType.addAll(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); + } finally { rwl.writeLock().unlock(); } diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java index b0e26cc80e..b418c1db4c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java @@ -1,7 +1,9 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.BaseUtils; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.icon.LockIcon; +import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.stable.StableUtils; @@ -11,6 +13,7 @@ import javax.swing.Icon; import javax.swing.UIManager; import javax.swing.filechooser.FileSystemView; import java.io.File; +import java.util.Set; public class FileTreeIcon { private FileTreeIcon() { @@ -146,16 +149,42 @@ public class FileTreeIcon { if (node.isDirectory()) { return FileTreeIcon.FOLDER_IMAGE_ICON; } - return FileSystemView.getFileSystemView().getSystemIcon(new File(path)); + return getLocalFileIcon(path); } } if (node.isDirectory()) { return FileTreeIcon.FOLDER_IMAGE_ICON; } else { - return FileTreeIcon.getIcon(FileTreeIcon.getFileType(node.getName()), isShowLock); + return getRemoteFileIcon(node, isShowLock); } } + private static Icon getLocalFileIcon(String path) { + Icon icon = getExtraIcon(path, false); + if (icon != null) { + return icon; + } + return FileSystemView.getFileSystemView().getSystemIcon(new File(path)); + } + + private static Icon getRemoteFileIcon(FileNode node, boolean isShowLock) { + Icon icon = getExtraIcon(node.getName(), isShowLock); + if (icon != null) { + return icon; + } + return FileTreeIcon.getIcon(FileTreeIcon.getFileType(node.getName()), isShowLock); + } + + private static Icon getExtraIcon(String path, boolean isShowLock) { + Set providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG); + for (ReportSupportedFileUIProvider provider : providers) { + if (provider.getFileIcon(path, isShowLock) != null) { + return provider.getFileIcon(path, isShowLock); + } + } + return null; + } + private static Icon getIcon(int fileType, boolean isLocked) { if (fileType == JAVA_FILE) { if (isLocked) { @@ -293,4 +322,4 @@ public class FileTreeIcon { return TEXT_FILE; } } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperNorthPane.java b/designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperNorthPane.java index c1e454f1b0..43710cd0f2 100644 --- a/designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperNorthPane.java +++ b/designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperNorthPane.java @@ -368,6 +368,7 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane { @Override public DBManipulationPane createDBManipulationPane() { - return new DBManipulationPane(); + JTemplate jTemplate = DesignerContext.getDesignerFrame().getSelectedJTemplate(); + return jTemplate == null ? new DBManipulationPane() : jTemplate.createDBManipulationPane(); } @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 56e119d6a7..082775a62d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -4,7 +4,6 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; -import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; @@ -113,9 +112,9 @@ import java.util.Set; public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener { - public static final String DESIGNER_FRAME_NAME = "designer_frame"; + private static final String DESIGNER_FRAME_NAME = "designer_frame"; - public static final Dimension MIN_SIZE = new Dimension(100, 100); + private static final Dimension MIN_SIZE = new Dimension(100, 100); private static final long serialVersionUID = -8732559571067484460L; @@ -145,9 +144,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private UIToolbar combineUp; - private NewTemplatePane newWorkBookPane = null; + private NewTemplatePane newWorkBookPane; - private Icon closeMode = UIConstants.CLOSE_OF_AUTHORITY; + private Icon closeMode; private JLayeredPane layeredPane = this.getLayeredPane(); @@ -184,7 +183,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); // 只有一个文件未保存时 - if (HistoryTemplateListPane.getInstance().getHistoryCount() == 1) { + if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) { int choose = saveSomeTempaltePane.saveLastOneTemplate(); if (choose != JOptionPane.CANCEL_OPTION) { DesignerFrame.this.exit(); @@ -318,7 +317,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public void componentResized(ComponentEvent e) { reCalculateFrameSize(); - if (DesignerMode.isAuthorityEditing()) { + if (DesignModeContext.isAuthorityEditing()) { doResize(); } } @@ -334,9 +333,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public void resizeFrame() { - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite(); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().setComposite(); reCalculateFrameSize(); - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize(); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().doResize(); } public void closeAuthorityEditing() { @@ -416,8 +415,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } /** - * @param ad - * @return + * @param ad 菜单栏 + * @return panel */ protected JPanel initNorthEastPane(final ToolBarMenuDock ad) { //hugh: private修改为protected方便oem的时候修改右上的组件构成 @@ -515,7 +514,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta protected ArrayList getFrameListeners() { - ArrayList arrayList = new ArrayList(); + ArrayList arrayList = new ArrayList<>(); arrayList.add(windowAdapter); return arrayList; } @@ -593,7 +592,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ public void refreshDottedLine() { - if (DesignerMode.isAuthorityEditing()) { + if (DesignModeContext.isAuthorityEditing()) { populateAuthorityArea(); populateCloseButton(); addDottedLine(); @@ -633,7 +632,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ private void fireAuthorityStateToNormal() { - java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); + List> opendedTemplate = HistoryTemplateListCache.getInstance().getHistoryList(); for (JTemplate jTemplate : opendedTemplate) { // 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表 if (jTemplate.isDoSomethingInAuthority()) { @@ -676,7 +675,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta for (UIButton fixButton : fixButtons) { combineUp.add(fixButton); } - if (!DesignerMode.isAuthorityEditing()) { + if (!DesignModeContext.isAuthorityEditing()) { combineUp.addSeparator(new Dimension(2, 16)); if (toolbar4Form != null) { for (JComponent jComponent : toolbar4Form) { @@ -692,7 +691,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private void addExtraButtons() { - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (jt == null) { return; } @@ -709,7 +708,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private void addShareButton() { - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (jt == null) { return; } @@ -784,13 +783,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ public void needToAddAuhtorityPaint() { - newWorkBookPane.setButtonGray(DesignerMode.isAuthorityEditing()); + newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing()); // 进入或退出权限编辑模式,通知插件 Set extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); for (ShortCut shortCut : extraShortCuts) { if (shortCut instanceof AbstractTemplateTreeShortCutProvider) { - shortCut.notifyFromAuhtorityChange(DesignerMode.isAuthorityEditing()); + shortCut.notifyFromAuhtorityChange(DesignModeContext.isAuthorityEditing()); } } } @@ -811,7 +810,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ public void setTitle() { - JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + JTemplate editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); StringBuilder defaultTitleSB = new StringBuilder(); defaultTitleSB.append(ProductConstants.PRODUCT_NAME); defaultTitleSB.append(" "); @@ -909,7 +908,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public void saveCurrentEditingTemplate() { - JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + JTemplate editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (editingTemplate == null) { return; } @@ -1092,7 +1091,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta if (inValidDesigner(jt)) { this.addAndActivateJTemplate(); MutilTempalteTabPane.getInstance().setTemTemplate( - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); } else { activeTemplate(jt); } @@ -1106,8 +1105,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ private void activeTemplate(JTemplate jt) { // 如果该模板已经打开,则进行激活就可以了 - int index = HistoryTemplateListPane.getInstance().contains(jt); - List> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); + int index = HistoryTemplateListCache.getInstance().contains(jt); + List> historyList = HistoryTemplateListCache.getInstance().getHistoryList(); if (index != -1) { historyList.get(index).activeJTemplate(index, jt); } else { @@ -1115,11 +1114,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } } - /** - * Exit退出 - */ - public void exit() { - + public void prepareForExit() { Thread thread = new Thread() { @Override @@ -1138,7 +1133,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } DesignerEnvManager.getEnvManager().setLastOpenFile( - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath()); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath()); DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( WestRegionContainerPane.getInstance().getToolPaneY()); @@ -1150,6 +1145,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta EastRegionContainerPane.getInstance().getContainerWidth()); DesignerEnvManager.getEnvManager().saveXMLFile(); + } + + /** + * Exit退出 + */ + public void exit() { + prepareForExit(); //关闭当前环境 WorkContext.getCurrent().close(); @@ -1251,7 +1253,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta /** * 更新进度框进度 * - * @param progress + * @param progress 进度值 */ public void updateProgress(int progress) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index c8f8280a49..2071215985 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -1,8 +1,10 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; +import com.fr.base.extension.FileExtension; import com.fr.base.vcs.DesignerMode; import com.fr.cluster.ClusterBridge; +import com.fr.cluster.engine.base.FineClusterConfig; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; @@ -367,17 +369,18 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt private void fireVcsActionChange() { if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.getInstance().isUnSelectedTemplate() - || ClusterBridge.isClusterMode()) { + || FineClusterConfig.getInstance().isCluster()) { setEnabled(false); return; } if (WorkContext.getCurrent() != null) { + boolean pathSupportVcsAction = selectedOperation.getFilePath() != null && pathSupportVcsAction(selectedOperation.getFilePath()); if (!WorkContext.getCurrent().isLocal()) { //当前环境为远程环境时 FileNode node = TemplateTreePane.getInstance().getTemplateFileTree().getSelectedFileNode(); - if (selectedOperation.getFilePath() != null) { + if (pathSupportVcsAction) { if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock())) { setEnabled(false); } else { @@ -388,11 +391,18 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } } else { //当前环境为本地环境时 - setEnabled(selectedOperation.getFilePath() != null); + setEnabled(pathSupportVcsAction); } } } + private boolean pathSupportVcsAction(String path) { + if (FileExtension.CPT.matchExtension(path) || FileExtension.FRM.matchExtension(path)) { + return true; + } + return false; + } + private void closeOpenedTemplate(String path, boolean isCurrentEditing) { for (JTemplate jTemplate : HistoryTemplateListCache.getInstance().getHistoryList()) { if (ComparatorUtils.equals(jTemplate.getEditingFILE().getPath(), path)) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 852130c1e0..31944deb03 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.base.FRContext; import com.fr.base.Parameter; import com.fr.base.ScreenResolution; +import com.fr.base.extension.FileExtension; import com.fr.base.io.BaseBook; import com.fr.base.iofile.attr.DesignBanCopyAttrMark; import com.fr.base.iofile.attr.TemplateIdAttrMark; @@ -12,7 +13,6 @@ import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.actions.AllowAuthorityEditAction; import com.fr.design.actions.TableDataSourceAction; import com.fr.design.actions.edit.RedoAction; import com.fr.design.actions.edit.UndoAction; @@ -27,6 +27,7 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; +import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.design.fun.PreviewProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; @@ -49,6 +50,7 @@ import com.fr.design.write.submit.DBManipulationPane; import com.fr.file.FILE; import com.fr.file.FILEChooserPane; import com.fr.file.MemFILE; +import com.fr.file.filter.ChooseFileFilter; import com.fr.form.ui.NoneWidget; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; @@ -575,6 +577,7 @@ public abstract class JTemplate> String oldName = this.getPath(); // alex:如果是SaveAs的话需要让用户来选择路径了 FILEChooserPane fileChooser = getFILEChooserPane(isShowLoc); + addChooseFILEFilter(fileChooser); fileChooser.setFileNameTextField(fileName, this.suffix()); int chooseResult = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), this.suffix()); @@ -625,6 +628,11 @@ public abstract class JTemplate> } } + protected void addChooseFILEFilter(FILEChooserPane fileChooser){ + + } + + // 保存新模板时会进入此方法(新建模板直接保存,或者另存为) protected boolean saveNewFile(FILE editingFILE, String oldName) { String originID = StringUtils.EMPTY; @@ -635,13 +643,26 @@ public abstract class JTemplate> initForCollect(); this.editingFILE = editingFILE; - boolean result = this.saveFile(); + boolean result = this.saveToNewFile(oldName); if (result) { DesignerFrameFileDealerPane.getInstance().refresh(); collectInfo(originID); } - //更换最近打开 - DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getPath()); + return result; + } + + protected boolean saveToNewFile(String oldName){ + boolean result = false; + Set providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG); + for (ReportSupportedFileUIProvider provider : providers) { + result = result || provider.saveToNewFile(this.editingFILE.getPath(), this); + } + if(!result){ + result = result || this.saveFile(); + //更换最近打开 + DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getPath()); + this.refreshToolArea(); + } return result; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java index 1ec8fe5e51..93c24ad699 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java @@ -5,7 +5,7 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.style.color.NewColorSelectBox; +import com.fr.design.style.color.ColorSelectBox; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.form.ui.Widget; import com.fr.form.ui.mobile.MobileStyle; @@ -23,7 +23,7 @@ public class MobileStyleDefinePane extends BasicBeanPane { private Widget widget; private MobileStyleCustomDefinePane customBeanPane; private Class mobileStyleClazz; - private NewColorSelectBox colorSelectBox; + private ColorSelectBox colorSelectBox; private Color titleColor = new Color(47, 142, 241); MobileStyleDefinePane(Widget widget, Class customBeanPaneClass, @@ -91,7 +91,7 @@ public class MobileStyleDefinePane extends BasicBeanPane { UILabel colorSelectLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Widget_Background"), UILabel.RIGHT); colorSelectLabel.setPreferredSize(new Dimension(65, 20)); - colorSelectBox = new NewColorSelectBox(152); + colorSelectBox = new ColorSelectBox(152); colorSelectBox.addSelectChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java index dc4af8750e..547ddf6ae6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.vcs.common; import com.fr.cluster.ClusterBridge; +import com.fr.cluster.engine.base.FineClusterConfig; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; import com.fr.design.file.HistoryTemplateListCache; @@ -173,7 +174,7 @@ public class VcsHelper implements JTemplateActionListener { public void templateSaved(JTemplate jt) { if (needInit() && DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() - && !ClusterBridge.isClusterMode()) { + && !FineClusterConfig.getInstance().isCluster()) { fireVcs(jt); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java index 73a8935dca..76434545ed 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java @@ -66,7 +66,7 @@ public class MobileTemplateStylePane extends AbstractTemplateStylePane centerPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"), null)); centerPane.add(previewPane); styleList.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { + public void mouseReleased(MouseEvent e) { previewPane.repaint((TemplateStyle) styleList.getSelectedValue()); } }); diff --git a/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java b/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java index 74cf7cbd35..9669b7cf92 100644 --- a/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java +++ b/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java @@ -15,6 +15,7 @@ import com.fr.design.parameter.ParameterDesignerProvider; import com.fr.design.parameter.ParameterReader; import com.fr.form.ui.Widget; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.solution.sandbox.collection.PluginSandboxCollections; import com.fr.stable.StableUtils; import org.jetbrains.annotations.NotNull; @@ -235,7 +236,7 @@ public class DesignModuleFactory { public static void registerParameterReader(ParameterReader reader) { if (instance.parameterReaderList == null) { - instance.parameterReaderList = new ArrayList(); + instance.parameterReaderList = PluginSandboxCollections.newSandboxList(); } instance.parameterReaderList.add(reader); } @@ -246,4 +247,4 @@ public class DesignModuleFactory { } return instance.parameterReaderList.toArray(new ParameterReader[instance.parameterReaderList.size()]); } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/os/impl/DemoAction.java b/designer-base/src/main/java/com/fr/design/os/impl/DemoAction.java index 8feb02952a..1696e6ce8a 100644 --- a/designer-base/src/main/java/com/fr/design/os/impl/DemoAction.java +++ b/designer-base/src/main/java/com/fr/design/os/impl/DemoAction.java @@ -21,13 +21,12 @@ public class DemoAction implements OSBasedAction { } String executorPath; - if (OperatingSystem.isMacos()) { executorPath = StableUtils.pathJoin(installHome, "bin", "designer.app"); } else if(OperatingSystem.isWindows()){ executorPath = StableUtils.pathJoin(installHome, "bin", "designer.exe demo"); }else{ - executorPath = StableUtils.pathJoin(installHome, "bin", "designer.sh demo"); + executorPath = StableUtils.pathJoin(installHome, "bin", "designer demo"); } if (OperatingSystem.isMacos()) { diff --git a/designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java b/designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java index b18254c113..d80fad5546 100644 --- a/designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java +++ b/designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java @@ -10,10 +10,19 @@ import java.util.ArrayList; import java.util.List; public class RestartAction implements OSBasedAction { + + private static String installHome; + + public RestartAction() { + installHome = StableUtils.getInstallHome(); + } + @Override public void execute(Object... objects) { String[] filesToBeDelete = (String[])objects; - String installHome = StableUtils.getInstallHome(); + if (installHome == null) { + installHome = StableUtils.getInstallHome(); + } try{ if (OperatingSystem.isMacos()) { restartInMacOS(installHome, filesToBeDelete); @@ -56,8 +65,7 @@ public class RestartAction implements OSBasedAction { private static void restartInLinux(String installHome, String[] filesToBeDelete) throws Exception { ProcessBuilder builder = new ProcessBuilder(); List commands = new ArrayList(); - //现在先写的是restart.sh - commands.add(installHome + File.separator + "bin" + File.separator + "restart.sh"); + commands.add(installHome + File.separator + "bin" + File.separator + "restart"); if (ArrayUtils.isNotEmpty(filesToBeDelete)) { commands.add(StableUtils.join(filesToBeDelete, "+")); } diff --git a/designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java b/designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java index 63929685d9..f48cb12edf 100644 --- a/designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java +++ b/designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java @@ -9,11 +9,14 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.remote.ui.AuthorityManagerPane; import com.fr.log.FineLoggerFactory; import com.fr.report.DesignAuthority; +import com.fr.report.constant.RoleType; import com.fr.stable.ArrayUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.server.authority.AuthorityOperator; import java.awt.event.ActionEvent; +import java.util.ArrayList; +import java.util.List; /** * @author yaohwu @@ -38,13 +41,24 @@ public class RemoteDesignAuthManagerAction extends UpdateAction { if (!WorkContext.getCurrent().isLocal()) { try { // 远程设计获取全部设计成员的权限列表 - DesignAuthority[] userAuthorities = WorkContext.getCurrent().get(AuthorityOperator.class).getUserAuthorities(); - DesignAuthority[] customAuthorities = WorkContext.getCurrent().get(AuthorityOperator.class).getCustomRoleAuthorities(); - if (userAuthorities != null && userAuthorities.length != 0) { - managerPane.populateByUser(userAuthorities); - } - if (customAuthorities != null && customAuthorities.length != 0) { - managerPane.populateByCustom(customAuthorities); + DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities(); + List userAuthorities = new ArrayList(); + List customAuthorities = new ArrayList(); + if (authorities != null) { + for (DesignAuthority authority : authorities) { + if (authority.getRoleType() == RoleType.CUSTOM) { + customAuthorities.add(authority); + } + else { + userAuthorities.add(authority); + } + } + if (userAuthorities.size() != 0) { + managerPane.populateByUser(userAuthorities.toArray(new DesignAuthority[userAuthorities.size()])); + } + if (customAuthorities.size() != 0) { + managerPane.populateByCustom(customAuthorities.toArray(new DesignAuthority[customAuthorities.size()])); + } } } catch (Exception exception) { FineLoggerFactory.getLogger().error(exception.getMessage(), exception); diff --git a/designer-base/src/main/java/com/fr/design/remote/ui/AbstractManagerPane.java b/designer-base/src/main/java/com/fr/design/remote/ui/AbstractManagerPane.java index 10ab1ffd5c..c92a7a8513 100644 --- a/designer-base/src/main/java/com/fr/design/remote/ui/AbstractManagerPane.java +++ b/designer-base/src/main/java/com/fr/design/remote/ui/AbstractManagerPane.java @@ -67,6 +67,12 @@ public abstract class AbstractManagerPane extends BasicPane { */ private List addedMembers = new ArrayList<>(); + + /** + * 具有设计权限的角色/用户 + */ + private List authorityMembers = new ArrayList<>(); + /** * 决策平台用户列表model */ @@ -211,6 +217,9 @@ public abstract class AbstractManagerPane extends BasicPane { resetAddedMembers(); this.addedMembers.addAll(addedMembers); + resetAuthorityMembers(); + this.authorityMembers.addAll(addedMembers); + // 刷新右侧面板 addToAddedMemberList(); @@ -314,15 +323,15 @@ public abstract class AbstractManagerPane extends BasicPane { private void addToMemberList() { addingListModel.clear(); - for (RemoteDesignMember addingMember : addingMembers) { + for (RemoteDesignMember member : addingMembers) { // 如果包含在右侧列表中,那么左侧列表默认选中 - for (RemoteDesignMember addedMember : addedMembers){ - if (addingMember.equals(addedMember)){ - addingMember.setAuthority(addedMember.hasAuthority()); - addingMember.setSelected(true); - } + if (addedMembers.contains(member)) { + member.setSelected(true); + } + else { + member.setSelected(false); } - addingListModel.addElement(addingMember); + addingListModel.addElement(member); } addingList.revalidate(); addingList.repaint(); @@ -350,6 +359,10 @@ public abstract class AbstractManagerPane extends BasicPane { addedMembers.clear(); } + private void resetAuthorityMembers() { + authorityMembers.clear(); + } + protected abstract Collection getMembers(String userName, String keyWord); protected abstract Collection getMembers(String userName, String keyWord, int pageNum, int count); @@ -376,6 +389,7 @@ public abstract class AbstractManagerPane extends BasicPane { @Override protected void done() { + referAddingMemberList(); addToMemberList(); } }; @@ -403,12 +417,22 @@ public abstract class AbstractManagerPane extends BasicPane { @Override protected void done() { + referAddingMemberList(); addToMemberList(); } }; loadMoreWorker.execute(); } + // 检查左侧列表角色/用户是否有权限 + private void referAddingMemberList() { + for (RemoteDesignMember member : addingMembers) { + if (authorityMembers.contains(member)){ + member.setAuthority(true); + } + } + } + private void sync2AddedMembersFromAdding() { RemoteDesignMember[] members = new RemoteDesignMember[addingListModel.getSize()]; diff --git a/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrPane.java b/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrPane.java index 55e11e9fd2..3381df3e46 100644 --- a/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrPane.java +++ b/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrPane.java @@ -50,7 +50,7 @@ public class ReportFitAttrPane extends BasicBeanPane { * @return 标题 */ protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Attr"); + return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_PC_Element_Case_Fit_Attr"); } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateFitAttrPane.java b/designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateFitAttrPane.java index 01b3196f5d..66673fc5f5 100644 --- a/designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateFitAttrPane.java +++ b/designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateFitAttrPane.java @@ -50,6 +50,6 @@ public class TemplateFitAttrPane extends BasicBeanPane { * @return 标题 */ protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Attr"); + return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_PC_Fit_Attr"); } } diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java b/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java index c8e3f9b8ac..93b9ba3fd0 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java @@ -4,7 +4,8 @@ package com.fr.design.style.color; * Created by plough on 2016/12/22. */ -import com.fr.base.BaseUtils; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import javax.swing.*; @@ -19,8 +20,7 @@ import java.awt.image.BufferedImage; /** * 取色框 */ -public class ColorPicker extends JDialog implements ActionListener -{ +public class ColorPicker extends JDialog implements ActionListener { private Container container = getContentPane(); // 主容器 private int setCoordinateX; // 取色框x坐标 private int setCoordinateY; // 取色框y坐标 @@ -42,8 +42,7 @@ public class ColorPicker extends JDialog implements ActionListener /** * 构造函数,创建一个取色框窗体 */ - public ColorPicker(ColorSelectable colorSelectable, Boolean setColorRealTime) - { + public ColorPicker(ColorSelectable colorSelectable, Boolean setColorRealTime) { setUndecorated(true); // 去掉窗体边缘 setResizable(false); Shape shape = new Ellipse2D.Double(0, 0, colorPickerSize, colorPickerSize); @@ -78,7 +77,6 @@ public class ColorPicker extends JDialog implements ActionListener } colorPickerPanel.captureScreen(); } -// System.out.println(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow()); } /** @@ -95,11 +93,33 @@ public class ColorPicker extends JDialog implements ActionListener public void updateLocation() { mousePos = MouseInfo.getPointerInfo().getLocation(); - setCoordinateX = mousePos.x - getSize().width/2; - setCoordinateY = mousePos.y- getSize().height/2; + updateCoordinate(); + setLocation(setCoordinateX, setCoordinateY); + updateMousePos(); + updateCoordinate(); colorPickerPanel.setMagnifierLocation(setCoordinateX, setCoordinateY); - setLocation(setCoordinateX, setCoordinateY); + + } + + private void updateCoordinate() { + setCoordinateX = mousePos.x - getSize().width / 2; + setCoordinateY = mousePos.y - getSize().height / 2; + } + + /** + * 兼容多屏下鼠标位置的计算 + */ + private void updateMousePos() { + Rectangle bounds = GUICoreUtils.getRectScreen(); + mousePos.x -= bounds.x; + mousePos.y -= bounds.y; + if (mousePos.x < 0) { + mousePos.x *= -1; + } + if (mousePos.y < 0) { + mousePos.y *= -1; + } } /** @@ -107,8 +127,7 @@ public class ColorPicker extends JDialog implements ActionListener * * @param colorPickerSize 取色框尺寸 */ - public void updateSize(int colorPickerSize) - { + public void updateSize(int colorPickerSize) { colorPickerPanel.setColorPickerSize(colorPickerSize); setSize(colorPickerSize, colorPickerSize); validate(); // 更新所有子控件 @@ -125,20 +144,19 @@ public class ColorPicker extends JDialog implements ActionListener // 隐藏鼠标光标 public void hideCursor() { Image imageCursor = Toolkit.getDefaultToolkit().getImage(""); - Cursor cu = Toolkit.getDefaultToolkit().createCustomCursor(imageCursor, new Point(0,0), "cursor"); + Cursor cu = Toolkit.getDefaultToolkit().createCustomCursor(imageCursor, new Point(0, 0), "cursor"); setCursor(cu); } - private class MouseFunctions extends MouseAdapter - { + private class MouseFunctions extends MouseAdapter { + @Override public void mousePressed(MouseEvent e) { - pickComplete(e.getButton() == e.BUTTON1); // 左键确定 + pickComplete(e.getButton() == MouseEvent.BUTTON1); // 左键确定 } } } -class ColorPickerPanel extends JPanel -{ +class ColorPickerPanel extends JPanel { private BufferedImage screenImage; private Image colorPickerFrame; // 取色框的边框图案 private int colorPickerSize; // 取色框尺寸 @@ -155,11 +173,11 @@ class ColorPickerPanel extends JPanel /** * 带参数的构造函数 - * @param scaleFactor 放大倍数 + * + * @param scaleFactor 放大倍数 */ - public ColorPickerPanel(int scaleFactor) - { - colorPickerFrame = BaseUtils.readImage("/com/fr/design/images/gui/colorPicker/colorPickerFrame.png"); + public ColorPickerPanel(int scaleFactor) { + colorPickerFrame = IOUtils.readImage("/com/fr/design/images/gui/colorPicker/colorPickerFrame.png"); this.scaleFactor = scaleFactor; captureScreen(); } @@ -168,26 +186,22 @@ class ColorPickerPanel extends JPanel * 截屏 */ public void captureScreen() { - try - { + try { robot = new Robot(); - } - catch (AWTException e) - { + } catch (AWTException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } // 截屏幕 - screenImage = robot.createScreenCapture(new Rectangle(0, 0, Toolkit - .getDefaultToolkit().getScreenSize().width, Toolkit - .getDefaultToolkit().getScreenSize().height)); + screenImage = robot.createScreenCapture(GUICoreUtils.getRectScreen()); } /** * 设置取色框的位置 - * @param locationX x坐标 - * @param locationY y坐标 + * + * @param locationX x坐标 + * @param locationY y坐标 */ - public void setMagnifierLocation(int locationX, int locationY) - { + public void setMagnifierLocation(int locationX, int locationY) { this.locationX = locationX; this.locationY = locationY; repaint(); // 注意重画控件 @@ -201,17 +215,16 @@ class ColorPickerPanel extends JPanel return new Color(R, G, B); } - public void setColorPickerSize(int colorPickerSize) - { + public void setColorPickerSize(int colorPickerSize) { this.colorPickerSize = colorPickerSize; } - public void paintComponent(Graphics g) - { + @Override + public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - double pixelCount = (double)colorPickerSize / scaleFactor; // 取色器一条边上的放大后的像素点个数(可以是小数) + double pixelCount = (double) colorPickerSize / scaleFactor; // 取色器一条边上的放大后的像素点个数(可以是小数) // 关键处理代码 g2d.drawImage( screenImage, // 要画的图片 @@ -219,10 +232,10 @@ class ColorPickerPanel extends JPanel 0, // 目标矩形的第一个角的y坐标 colorPickerSize, // 目标矩形的第二个角的x坐标 colorPickerSize, // 目标矩形的第二个角的y坐标 - locationX + (int)((colorPickerSize - pixelCount) * 0.5) + 1, // 源矩形的第一个角的x坐标 - locationY + (int)((colorPickerSize - pixelCount) * 0.5) + 1, // 源矩形的第一个角的y坐标 - locationX + (int)((colorPickerSize + pixelCount) * 0.5) + 1, // 源矩形的第二个角的x坐标 - locationY + (int)((colorPickerSize + pixelCount) * 0.5) + 1, // 源矩形的第二个角的y坐标 + locationX + (int) ((colorPickerSize - pixelCount) * 0.5) + 1, // 源矩形的第一个角的x坐标 + locationY + (int) ((colorPickerSize - pixelCount) * 0.5) + 1, // 源矩形的第一个角的y坐标 + locationX + (int) ((colorPickerSize + pixelCount) * 0.5) + 1, // 源矩形的第二个角的x坐标 + locationY + (int) ((colorPickerSize + pixelCount) * 0.5) + 1, // 源矩形的第二个角的y坐标 this ); g2d.drawImage(colorPickerFrame, 0, 0, this); diff --git a/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java index d4f878f5f9..eb25ccea30 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java @@ -3,14 +3,14 @@ package com.fr.design.update.actions; import com.fr.decision.update.backup.Recover; import com.fr.decision.update.data.UpdateConstants; import com.fr.decision.update.exception.UpdateException; +import com.fr.design.mainframe.DesignerContext; import com.fr.general.CommonIOUtils; import com.fr.general.GeneralUtils; -import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.CommonUtils; +import com.fr.stable.ProjectLibrary; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; -import com.fr.workspace.WorkContext; import java.io.File; import java.io.IOException; @@ -22,59 +22,82 @@ import java.io.IOException; */ public class RecoverForDesigner implements Recover { + private final String installHome = StableUtils.getInstallHome(); + @Override public boolean recover() { try{ - CommonIOUtils.copyFilesInDirByPath(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNERBACKUPPATH), + CommonIOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome, ProjectConstants.LOGS_NAME, + UpdateConstants.INSTALL_LIB, UpdateConstants.DESIGNERBACKUPPATH), StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LIB_NAME)); return true; } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage() + "Recover error for designer"); + FineLoggerFactory.getLogger().error("Recover error for designer", e); return false; } } @Override public boolean backup() { - String installHome = StableUtils.getInstallHome(); //jar包备份文件的目录为"backup/"+jar包当前版本号 String todayBackupDir = StableUtils.pathJoin(installHome, UpdateConstants.DESIGNER_BACKUP_DIR, (GeneralUtils.readBuildNO())); - backupFilesFromInstallEnv(todayBackupDir); + String envHome = ProjectLibrary.getInstance().getLibHome(); + backupFilesFromInstallEnv(envHome, todayBackupDir); backupFilesFromInstallLib(installHome, todayBackupDir); try { - File file = new File(StableUtils.pathJoin(installHome, UpdateConstants.DOWNLOADPATH)); - CommonUtils.mkdirs(file); - IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), - StableUtils.pathJoin(installHome, UpdateConstants.DESIGNERBACKUPPATH)); + String installBackup = StableUtils.pathJoin(installHome, ProjectConstants.LOGS_NAME, + UpdateConstants.INSTALL_LIB); + File installLib = new File(installBackup); + CommonUtils.mkdirs(installLib); + File download = new File(StableUtils.pathJoin(installBackup,UpdateConstants.DOWNLOADPATH)); + CommonUtils.mkdirs(download); + CommonIOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), + StableUtils.pathJoin(installBackup,UpdateConstants.DESIGNERBACKUPPATH)); + DesignerContext.getDesignerFrame().prepareForExit(); return true; - }catch (IOException e) { + } catch (IOException e) { UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage()); FineLoggerFactory.getLogger().error(exception.getMessage(),exception); return false; } } - private void backupFilesFromInstallEnv(String todayBackupDir) { + private void backupFilesFromInstallEnv(String envHome, String todayBackupDir) { try { - CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH))); - IOUtils.copyFilesInDirByPath( - StableUtils.pathJoin(WorkContext.getCurrent().getPath(),ProjectConstants.LIB_NAME), - StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)); + File file = new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)); + CommonUtils.mkdirs(file); + file = new File(StableUtils.pathJoin(envHome,ProjectConstants.LIB_NAME)); + File[] files = file.listFiles(); + File dir = new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)); + if (files != null) { + for (File file1 : files) { + if (file1.getName().startsWith(UpdateConstants.FINE) && file1.getName().endsWith(UpdateConstants.JAR_FILE_SUFFIX)) { + CommonIOUtils.copy(file1, dir); + } + } + } } catch (IOException e) { UpdateException exception = new UpdateException(e.getMessage()); - FineLoggerFactory.getLogger().error(exception.getMessage() + "backup for Designer recover in env failed"); + FineLoggerFactory.getLogger().error(exception.getMessage() , "backup for Designer recover in env failed"); } } private void backupFilesFromInstallLib(String installHome, String todayBackupDir) { try { CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH))); - IOUtils.copyFilesInDirByPath( - StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), - StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH)); + File lib = new File(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME)); + File[] files = lib.listFiles(); + File dir = new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH)); + if (files != null) { + for (File file : files) { + if (file.getName().startsWith(UpdateConstants.FINE) || file.getName().contains(UpdateConstants.ASPECTJRT)) { + CommonIOUtils.copy(file, dir); + } + } + } } catch (IOException e) { UpdateException exception = new UpdateException(e.getMessage()); - FineLoggerFactory.getLogger().error(exception.getMessage() + "backup for Designer recover in install failed"); + FineLoggerFactory.getLogger().error(exception.getMessage() , "backup for Designer recover in install failed"); } } } diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java index 83ffbe5fe2..7522041ff0 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java @@ -10,7 +10,6 @@ import com.fr.general.ComparatorUtils; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; -import com.fr.workspace.WorkContext; import javax.swing.AbstractAction; import javax.swing.BorderFactory; @@ -143,7 +142,6 @@ public class RestoreResultDialog extends JDialog { jTextArea.setFont(new Font("Default", Font.PLAIN, 12)); infoPane.add(jTextArea); pane.add(infoPane, BorderLayout.CENTER); - this.setSize(RESTORE_OLD_VERSION); this.setTitle(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Updater_Restore_to_V8")); } @@ -162,34 +160,68 @@ public class RestoreResultDialog extends JDialog { List list = new ArrayList<>(); String installHome = StableUtils.getInstallHome(); - putJarBackupFilesToInstallLib(installHome, map, list); - putJarBackupFilesToInstallEnv(installHome, map, list); + filesToMove(installHome, map); + filesToDelete(installHome, list); RestartHelper.saveFilesWhichToMove(map); RestartHelper.saveFilesWhichToDelete(list.toArray(new String[list.size()])); } - private void putJarBackupFilesToInstallLib(String installHome, Map map, List list) { + private void filesToMove(String installHome, Map map) { String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR; + String envHome = StableUtils.pathJoin(installHome, UpdateConstants.WEBAPPS, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME); File installLib = new File(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, UpdateConstants.DESIGNERBACKUPPATH)); - File[] files = installLib.listFiles(); - if (files != null) { - for (File file : files) { - map.put(file.getAbsolutePath(), - StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file.getName())); - list.add(StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file.getName())); + File envLib = new File(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, UpdateConstants.BACKUPPATH)); + File[] files; + if (installLib.exists() && envLib.exists()) { + files = installLib.listFiles(); + if (files != null) { + for (File file : files) { + map.put(file.getAbsolutePath(), + StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file.getName())); + } + } + files = envLib.listFiles(); + if (files != null) { + for (File file : files) { + map.put(file.getAbsolutePath(), + StableUtils.pathJoin(envHome, ProjectConstants.LIB_NAME, file.getName())); + } + } + } else { + installLib = new File(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir)); + files = installLib.listFiles(); + if (files != null) { + for (File file : files) { + if (file.getName().contains(UpdateConstants.DESIGNER) || file.getName().equals(UpdateConstants.ASPECTJRT)) { + map.put(file.getAbsolutePath(), + StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file.getName())); + } else { + map.put(file.getAbsolutePath(), + StableUtils.pathJoin(envHome, ProjectConstants.LIB_NAME, file.getName())); + } + } } } } - private void putJarBackupFilesToInstallEnv(String installHome, Map map, List list) { - String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR; - File installEnv = new File(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, UpdateConstants.BACKUPPATH)); + private void filesToDelete(String installHome, List list) { + String envHome = StableUtils.pathJoin(installHome, UpdateConstants.WEBAPPS, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME); + File installEnv = new File(StableUtils.pathJoin(envHome,ProjectConstants.LIB_NAME)); File[] files = installEnv.listFiles(); if (files != null) { for (File file : files) { - map.put(file.getAbsolutePath(), - StableUtils.pathJoin(WorkContext.getCurrent().getPath(), ProjectConstants.LIB_NAME, file.getName())); - list.add(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), ProjectConstants.LIB_NAME, file.getName())); + if (file.getName().startsWith(UpdateConstants.FINE)) { + list.add(StableUtils.pathJoin(envHome, ProjectConstants.LIB_NAME, file.getName())); + } + } + } + installEnv = new File(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME)); + files = installEnv.listFiles(); + if (files != null) { + for (File file : files) { + if (file.getName().startsWith(UpdateConstants.FINE) || file.getName().contains(UpdateConstants.ASPECTJRT)) { + list.add(StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file.getName())); + } } } } diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index e8f3e5986b..1fb21d41cb 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java @@ -30,6 +30,7 @@ import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.*; +import com.fr.stable.project.ProjectConstants; import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; import com.fr.third.org.apache.http.client.methods.HttpGet; import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; @@ -47,10 +48,8 @@ import java.io.*; import java.nio.charset.StandardCharsets; import java.text.ParsePosition; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; +import java.util.*; import java.util.List; -import java.util.Locale; import java.util.concurrent.ExecutionException; import static java.nio.charset.StandardCharsets.*; @@ -594,19 +593,23 @@ public class UpdateMainDialog extends UIDialog { UpdateCallBack callBack = new UpdateProgressCallBack(progressBar); updateButton.setEnabled(false); updateLabel.setVisible(false); + RestoreResultDialog.deletePreviousPropertyFile(); + final String installLib = StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LOGS_NAME, UpdateConstants.INSTALL_LIB); + final JFrame frame = DesignerContext.getDesignerFrame(); + final RestartHelper helper = new RestartHelper(); new FileProcess(callBack) { @Override public void onDownloadSuccess() { progressBar.setVisible(false); - deleteForDesignerUpdate(); - RestartHelper.restart(); + deleteForDesignerUpdate(installLib); + helper.restartForUpdate(frame); } @Override public void onDownloadFailed() { progressBar.setVisible(false); - deleteForDesignerUpdate(); + deleteForDesignerUpdate(installLib); JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); - RestartHelper.restart(); + helper.restartForUpdate(frame); } }.execute(); } @@ -614,11 +617,9 @@ public class UpdateMainDialog extends UIDialog { }); } - private void deleteForDesignerUpdate() { - File designerBackup = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DESIGNERBACKUPPATH)); - CommonUtils.deleteFile(designerBackup); - File downloadForDesigner = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DOWNLOADPATH)); - CommonUtils.deleteFile(downloadForDesigner); + private void deleteForDesignerUpdate(String installLib) { + File dir = new File(installLib); + CommonUtils.deleteFile(dir); } //获取备份目录 diff --git a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java index 12fc96e966..f0412a948b 100644 --- a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java @@ -79,6 +79,8 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.image.BufferedImage; import java.awt.image.ImageObserver; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -967,4 +969,16 @@ public final class GUICoreUtils { } return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 10); } + + /** + * 获取当前所有显示器设备的总长总宽 + * @return + */ + public static Rectangle getRectScreen() { + Rectangle rectangle = new Rectangle(0, 0, 0, 0); + for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) { + rectangle = rectangle.union(gd.getDefaultConfiguration().getBounds()); + } + return rectangle; + } } diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index d273a00a2d..20f698a3fa 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -52,15 +52,16 @@ import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; -import java.util.concurrent.ExecutionException; import static com.fr.design.layout.TableLayout.FILL; import static com.fr.design.layout.TableLayout.PREFERRED; +import static com.fr.env.TestConnectionResult.AUTH_FAILED; import static com.fr.third.guava.base.Optional.fromNullable; /** * @author yaohwu */ +@SuppressWarnings("squid:MaximumInheritanceDepth") public class RemoteEnvPane extends BasicBeanPane { private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92); @@ -118,6 +119,7 @@ public class RemoteEnvPane extends BasicBeanPane { /** * 主机位置 */ + @SuppressWarnings("squid:S1948") private RemoteWorkspaceURL remoteWorkspaceURL = new RemoteWorkspaceURL(""); /** * https 配置面板 @@ -138,6 +140,7 @@ public class RemoteEnvPane extends BasicBeanPane { /** * 主机名,web应用,Servlet,端口监听器 */ + @SuppressWarnings("squid:S1948") private DocumentListener individualDocListener = new DocumentListener() { @Override @@ -148,19 +151,32 @@ public class RemoteEnvPane extends BasicBeanPane { @Override public void insertUpdate(DocumentEvent e) { - updateRemoteURL(); - fillRemoteEnvURLField(); + changedUpdate(e); } @Override public void removeUpdate(DocumentEvent e) { - updateRemoteURL(); - fillRemoteEnvURLField(); + changedUpdate(e); + } + + private void updateRemoteURL() { + boolean isHttps = httpsCheckbox.isSelected(); + String host = hostNameInput.getText(); + String port = portInput.getText(); + String web = webAppNameInput.getText(); + String servlet = servletNameInput.getText(); + remoteWorkspaceURL.setHttps(isHttps); + remoteWorkspaceURL.setHost(host); + remoteWorkspaceURL.setPort(port); + remoteWorkspaceURL.setWeb(web); + remoteWorkspaceURL.setServlet(servlet); + remoteWorkspaceURL.resetUrl(); } }; /** * 路径输入框监听器 */ + @SuppressWarnings("squid:S1948") private DocumentListener overallDocListener = new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { @@ -169,7 +185,6 @@ public class RemoteEnvPane extends BasicBeanPane { @Override public void removeUpdate(DocumentEvent e) { - actionURLInputChange(); } @@ -177,10 +192,22 @@ public class RemoteEnvPane extends BasicBeanPane { public void changedUpdate(DocumentEvent e) { actionURLInputChange(); } + + private void actionURLInputChange() { + remoteWorkspaceURL = new RemoteWorkspaceURL(remoteEnvURLInput.getText()); + fillIndividualField(); + + httpsCheckbox.setSelected(remoteWorkspaceURL.getHttps()); + boolean isHttps = httpsCheckbox.isSelected(); + DesignerEnvManager.getEnvManager().setHttps(isHttps); + fileChooserButton.setEnabled(isHttps); + updateHttpsConfigPanel(); + } }; /** * https checkbox listener */ + @SuppressWarnings("squid:S1948") private ActionListener httpsCheckboxListener = new ActionListener() { @Override @@ -523,17 +550,17 @@ public class RemoteEnvPane extends BasicBeanPane { final RemoteDesignerWorkspaceInfo remoteEnv = updateBean(); final WorkspaceConnectionInfo connection = remoteEnv.getConnection(); - final SwingWorker worker = new SwingWorker() { + final SwingWorker worker = new SwingWorker() { @Override - protected Boolean doInBackground() throws Exception { + protected TestConnectionResult doInBackground() throws Exception { DesignerEnvManager.getEnvManager().setCertificatePath(connection.getCertPath()); DesignerEnvManager.getEnvManager().setCertificatePass(connection.getCertSecretKey()); try { - return WorkContext.getConnector().testConnection(connection); + return TestConnectionResult.parse(WorkContext.getConnector().testConnection(connection), connection); } catch (WorkspaceAuthException ignored) { - return null; + return AUTH_FAILED; } } @@ -541,14 +568,13 @@ public class RemoteEnvPane extends BasicBeanPane { protected void done() { okButton.setEnabled(true); try { - TestConnectionResult result = TestConnectionResult.parse(get(), connection); + TestConnectionResult result = get(); message.setText(result.getText()); uiLabel.setIcon(result.getIcon()); - } catch (InterruptedException | ExecutionException e) { + } catch (Exception e) { FineLoggerFactory.getLogger().error(e, e.getMessage()); message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed")); uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); - Thread.currentThread().interrupt(); } dialogDownPane.remove(cancelButton); dialogDownPane.revalidate(); @@ -633,35 +659,10 @@ public class RemoteEnvPane extends BasicBeanPane { enableSubDocListener(); } - private void updateRemoteURL() { - boolean isHttps = httpsCheckbox.isSelected(); - String host = hostNameInput.getText(); - String port = portInput.getText(); - String web = webAppNameInput.getText(); - String servlet = servletNameInput.getText(); - remoteWorkspaceURL.setHttps(isHttps); - remoteWorkspaceURL.setHost(host); - remoteWorkspaceURL.setPort(port); - remoteWorkspaceURL.setWeb(web); - remoteWorkspaceURL.setServlet(servlet); - } - - private void updateHttpsConfigPanel() { httpsConfigPanel.removeAll(); packHttpsConfigPanel(); httpsConfigPanel.revalidate(); httpsConfigPanel.repaint(); } - - private void actionURLInputChange() { - remoteWorkspaceURL = new RemoteWorkspaceURL(remoteEnvURLInput.getText()); - fillIndividualField(); - - httpsCheckbox.setSelected(remoteWorkspaceURL.getHttps()); - boolean isHttps = httpsCheckbox.isSelected(); - DesignerEnvManager.getEnvManager().setHttps(isHttps); - fileChooserButton.setEnabled(isHttps); - updateHttpsConfigPanel(); - } } diff --git a/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java b/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java index f7f5e6aeeb..dee40422c7 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java +++ b/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java @@ -1,10 +1,9 @@ package com.fr.env; +import com.fr.stable.AssistUtils; import com.fr.stable.FCloneable; import com.fr.stable.StringUtils; -import java.util.Objects; - /** * @author yaohwu */ @@ -42,6 +41,7 @@ public class RemoteWorkspaceURL implements FCloneable { private String port; private String web; private String servlet; + private String url; /** @@ -51,7 +51,7 @@ public class RemoteWorkspaceURL implements FCloneable { * @param url x:x/x/x/x */ public RemoteWorkspaceURL(String url) { - + this.url = url; // 没有写协议名称 默认 使用 http 协议 if (!url.startsWith(HTTPS) && !url.startsWith(HTTP)) { url = HTTP + url; @@ -116,11 +116,15 @@ public class RemoteWorkspaceURL implements FCloneable { } public String getURL() { + if (this.url != null) { + return url; + } String prefix = isHttps ? HTTPS : HTTP; String portColon = StringUtils.isNotEmpty(port) ? ":" : StringUtils.EMPTY; String webAppNameSlash = StringUtils.isNotEmpty(web) ? "/" : StringUtils.EMPTY; String servletNameSlash = StringUtils.isNotEmpty(servlet) ? "/" : StringUtils.EMPTY; - return prefix + host + portColon + port + webAppNameSlash + web + servletNameSlash + servlet; + this.url = prefix + host + portColon + port + webAppNameSlash + web + servletNameSlash + servlet; + return this.url; } @@ -164,26 +168,24 @@ public class RemoteWorkspaceURL implements FCloneable { return servlet; } + public void resetUrl() { + this.url = null; + } + @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - RemoteWorkspaceURL that = (RemoteWorkspaceURL) o; - return isHttps == that.isHttps && - Objects.equals(host, that.host) && - Objects.equals(port, that.port) && - Objects.equals(web, that.web) && - Objects.equals(servlet, that.servlet); + return o instanceof RemoteWorkspaceURL && AssistUtils.equals(isHttps, ((RemoteWorkspaceURL) o).isHttps) + && AssistUtils.equals(host, ((RemoteWorkspaceURL) o).host) + && AssistUtils.equals(port, ((RemoteWorkspaceURL) o).port) + && AssistUtils.equals(web, ((RemoteWorkspaceURL) o).web) + && AssistUtils.equals(servlet, ((RemoteWorkspaceURL) o).servlet) + && AssistUtils.equals(url, ((RemoteWorkspaceURL) o).url); } @Override public int hashCode() { - return Objects.hash(isHttps, host, port, web, servlet); + return AssistUtils.hashCode(isHttps, host, port, web, servlet, url); } @Override @@ -194,6 +196,7 @@ public class RemoteWorkspaceURL implements FCloneable { ", port='" + port + '\'' + ", web='" + web + '\'' + ", servlet='" + servlet + '\'' + + ", url='" + url + '\'' + '}'; } diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index fc4a5dfea0..52e63c9bfa 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -4,12 +4,14 @@ import com.fr.base.BaseUtils; import com.fr.base.FRContext; import com.fr.base.extension.FileExtension; import com.fr.design.DesignerEnvManager; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.UIDialog; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.icombobox.UIComboBox; @@ -31,6 +33,8 @@ import com.fr.file.filter.FILEFilter; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.log.FineLoggerFactory; +import com.fr.report.ExtraReportClassManager; +import com.fr.report.fun.ReportSupportedFileProvider; import com.fr.stable.CoreConstants; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; @@ -90,6 +94,7 @@ import java.util.ArrayList; import java.util.EnumSet; import java.util.Iterator; import java.util.List; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -475,8 +480,11 @@ public class FILEChooserPane extends BasicPane { @Override public void itemStateChanged(ItemEvent e) { Object ss = postfixComboBox.getSelectedItem(); - if (ss instanceof FILEFilter) { - setFILEFilter((FILEFilter) ss); + if (ss instanceof ChooseFileFilter) { + setFILEFilter((ChooseFileFilter) ss); + if (fileNameTextField.isShowing()) { + fileNameTextField.setText(calProperFileName(fileNameTextField.getText(), (ChooseFileFilter) ss)); + } } else { setFILEFilter(null); } @@ -484,6 +492,21 @@ public class FILEChooserPane extends BasicPane { }); } + private String calProperFileName(String fileName, ChooseFileFilter fileFilter) { + if(fileFilter == null){ + return fileName; + } + String filterExtension = fileFilter.getExtensionString(); + int lastDotIndex = fileName.lastIndexOf(".") != -1 ? fileName.lastIndexOf(".") : fileName.length(); + String fileNameWithOutExtension = fileName.substring(0, lastDotIndex); + String fileNameExtension = fileName.substring(lastDotIndex); + FileExtension fileExtension = FileExtension.parse(fileNameExtension); + if (StringUtils.isEmpty(fileName) || StringUtils.isEmpty(filterExtension) || fileFilter.containsExtension(fileExtension.getExtension())) { + return fileName; + } + return fileNameWithOutExtension + filterExtension; + } + private void doCancel() { this.locationBtnPane.setPopDir(null); dialogExit(); @@ -720,16 +743,26 @@ public class FILEChooserPane extends BasicPane { if (editing == null || !editing.isChartBook()) { if (type == JFileChooser.OPEN_DIALOG) { - this.addChooseFILEFilter(new ChooseFileFilter(FRContext.getFileNodes().getSupportedTypes(), appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); + ChooseFileFilter supportedTypes = new ChooseFileFilter(FRContext.getFileNodes().getSupportedTypes(), appName + Toolkit.i18nText("Fine-Design_Report_Template_File")); + Set providers = ExtraReportClassManager.getInstance().getArray(ReportSupportedFileProvider.XML_TAG); + for (ReportSupportedFileProvider provider : providers) { + for (FileExtension fileExtension : provider.getFileExtensions()){ + supportedTypes.addExtension(fileExtension.getExtension()); + } + } + this.addChooseFILEFilter(supportedTypes); } // ben:filefilter设置初值为cpt过滤 this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPT, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPTX, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); // richer:form文件 daniel 改成三个字 this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRM, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRMX, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); + + Set providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG); + for (ReportSupportedFileUIProvider provider : providers) { + provider.addChooseFileFilter(this, StringUtils.EMPTY); + } } else { if (type == JFileChooser.OPEN_DIALOG) { this.addChooseFILEFilter(new ChooseFileFilter(EnumSet.of(FileExtension.XLS, FileExtension.XLSX), Toolkit.i18nText("Fine-Design_Basic_Import_Excel_Source"))); @@ -782,12 +815,7 @@ public class FILEChooserPane extends BasicPane { } } //jerry 26216 只保留.cpt .frm有用的格式,并且不可编辑 - if (type == JFileChooser.OPEN_DIALOG) { - postfixComboBox.setEnabled(true); - } else { - postfixComboBox.setEnabled(false); - } - + postfixComboBox.setEnabled(true); //只有一个类型时不可下拉 if (filterList.size() == 1) { postfixComboBox.setEnabled(false); @@ -841,14 +869,8 @@ public class FILEChooserPane extends BasicPane { private void saveDialog() { String filename = fileNameTextField.getText(); - if (!filename.endsWith(suffix)) { - ChooseFileFilter chooseFileFilter = (ChooseFileFilter) (postfixComboBox.getSelectedItem()); - if (chooseFileFilter != null && StringUtils.isNotEmpty(chooseFileFilter.getExtensionString())) { - fileNameTextField.setText(filename + chooseFileFilter.getExtensionString()); - } else { - fileNameTextField.setText(filename + this.suffix); - } - } + filename = calProperFileName(filename, (ChooseFileFilter) (postfixComboBox.getSelectedItem())); + fileNameTextField.setText(filename); option = OK_OPTION; FILE selectedFile = this.getSelectedFILE(); @@ -874,6 +896,7 @@ public class FILEChooserPane extends BasicPane { } } + private boolean access(FILE selectedFile) { boolean access = false; try { diff --git a/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java b/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java index 67f0824567..3358ac8be9 100644 --- a/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java +++ b/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java @@ -1,51 +1,63 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.extension.FileExtension; -import com.fr.base.io.BaseBook; -import com.fr.design.ExtraDesignClassManager; -import com.fr.design.mainframe.AbstractAppProvider; -import com.fr.design.mainframe.App; -import com.fr.design.mainframe.JTemplate; -import com.fr.file.FILE; +import com.fr.report.ExtraReportClassManager; +import com.fr.report.fun.ReportSupportedFileProvider; +import com.fr.report.fun.impl.AbstractReportSupportedFileProvider; import com.fr.stable.fun.mark.Mutable; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Test; - +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import java.util.HashSet; import java.util.Set; /** * Created by alex sung on 2019/7/25. */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(ExtraReportClassManager.class) public class FileNodeConstantsTest { @Test - public void supportFileTypesTest(){ - ExtraDesignClassManager extra = EasyMock.mock(ExtraDesignClassManager.class); - Set apps = new HashSet(){{add(new MockCptxApp());}}; - EasyMock.expect(extra.getArray(App.MARK_STRING)).andReturn(apps).anyTimes(); - EasyMock.replay(extra); + public void supportFileTypesTest() { + ExtraReportClassManager extra = mockExtraReportClassManager(); + Assert.assertEquals(1, extra.getArray(ReportSupportedFileProvider.XML_TAG).size()); + ReportSupportedFileProvider option = (ReportSupportedFileProvider) extra.getArray(ReportSupportedFileProvider.XML_TAG).iterator().next(); + Assert.assertEquals(FileExtension.CPTX, option.getFileExtensions()[0]); + } - Assert.assertEquals(1, extra.getArray(App.MARK_STRING).size()); - App app = (App) extra.getArray(App.MARK_STRING).iterator().next(); - Assert.assertEquals("cptx", app.defaultExtensions()[0]); + @Test + public void testSupportFileTypesOrder() { + ExtraReportClassManager extra = mockExtraReportClassManager(); + PowerMock.mockStatic(ExtraReportClassManager.class); + EasyMock.expect(ExtraReportClassManager.getInstance()).andReturn(extra).once(); + PowerMock.replayAll(); + String[] fileTypes = FileNodeConstants.getSupportFileTypes(); + Assert.assertEquals("cptx", fileTypes[0]); + Assert.assertEquals("cpt", fileTypes[1]); } - private class MockCptxApp extends AbstractAppProvider{ - @Override - public String[] defaultExtensions() { - return new String[] {FileExtension.CPTX.getExtension()}; - } + private ExtraReportClassManager mockExtraReportClassManager() { + ExtraReportClassManager extra = EasyMock.mock(ExtraReportClassManager.class); + Set options = new HashSet() {{ + add(new MockNewTemplateFileOption()); + }}; + EasyMock.expect(extra.getArray(ReportSupportedFileProvider.XML_TAG)).andReturn(options).anyTimes(); + EasyMock.replay(extra); + return extra; + } - @Override - public JTemplate openTemplate(FILE tplFile) { - return null; - } + private class MockNewTemplateFileOption extends AbstractReportSupportedFileProvider { @Override - public BaseBook asIOFile(FILE tplFile) { - return null; + public FileExtension[] getFileExtensions() { + return new FileExtension[]{FileExtension.CPTX + }; } + } } diff --git a/designer-base/src/test/java/com/fr/env/RemoteEnvURLTest.java b/designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java similarity index 75% rename from designer-base/src/test/java/com/fr/env/RemoteEnvURLTest.java rename to designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java index 2c6a0ab39a..f066ae6896 100644 --- a/designer-base/src/test/java/com/fr/env/RemoteEnvURLTest.java +++ b/designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java @@ -4,11 +4,57 @@ import org.junit.Assert; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; /** * @author yaohwu */ -public class RemoteEnvURLTest { +public class RemoteWorkspaceURLTest { + + + @Test + public void testEqualAndHashCode() { + String a = "https://yaohwu:8080/webroot/app/c/d"; + RemoteWorkspaceURL workspaceURL1 = new RemoteWorkspaceURL(a); + RemoteWorkspaceURL workspaceURL2 = new RemoteWorkspaceURL(a); + assertEquals(workspaceURL1.hashCode(), workspaceURL2.hashCode()); + assertEquals(workspaceURL1, workspaceURL2); + workspaceURL2.resetUrl(); + assertNotEquals(workspaceURL1.hashCode(), workspaceURL2.hashCode()); + assertNotEquals(workspaceURL1, workspaceURL2); + } + + @Test + public void testUrlReset() { + + String a = "https://yaohwu:8080/webroot/app/c/d"; + RemoteWorkspaceURL workspaceURL = new RemoteWorkspaceURL(a); + Assert.assertEquals(a, workspaceURL.getURL()); + Assert.assertEquals("app", workspaceURL.getServlet()); + Assert.assertEquals("webroot", workspaceURL.getWeb()); + Assert.assertEquals("yaohwu", workspaceURL.getHost()); + Assert.assertEquals("8080", workspaceURL.getPort()); + Assert.assertTrue(workspaceURL.getHttps()); + + workspaceURL.setHttps(false); + workspaceURL.setHost("finereport"); + + Assert.assertEquals(a, workspaceURL.getURL()); + Assert.assertEquals("app", workspaceURL.getServlet()); + Assert.assertEquals("webroot", workspaceURL.getWeb()); + Assert.assertEquals("finereport", workspaceURL.getHost()); + Assert.assertEquals("8080", workspaceURL.getPort()); + Assert.assertFalse(workspaceURL.getHttps()); + + workspaceURL.resetUrl(); + + Assert.assertEquals("http://finereport:8080/webroot/app", workspaceURL.getURL()); + Assert.assertEquals("app", workspaceURL.getServlet()); + Assert.assertEquals("webroot", workspaceURL.getWeb()); + Assert.assertEquals("finereport", workspaceURL.getHost()); + Assert.assertEquals("8080", workspaceURL.getPort()); + Assert.assertFalse(workspaceURL.getHttps()); + } @Test public void testURLParser() { diff --git a/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java b/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java new file mode 100644 index 0000000000..c8431a8621 --- /dev/null +++ b/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java @@ -0,0 +1,39 @@ +package com.fr.file; + +import com.fr.base.extension.FileExtension; +import com.fr.file.filter.ChooseFileFilter; +import com.fr.invoke.Reflect; +import com.fr.stable.StringUtils; +import org.junit.Assert; +import org.junit.Test; + +/** + * Created by kerry on 2019-10-15 + */ + +public class FILEChooserPaneTest { + @Test + public void testAddChooseFileFilter() { + FILEChooserPane chooserPane = Reflect.on(FILEChooserPane.class).field("INSTANCE").get(); + Reflect.on(chooserPane).set("suffix", ".cpt"); + String result1 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", null).get(); + Assert.assertEquals("WorkBook1.cpt", result1); + + ChooseFileFilter chooseFileFilter1 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); + String result2 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", chooseFileFilter1).get(); + Assert.assertEquals("WorkBook1.cpt", result2); + + ChooseFileFilter chooseFileFilter2 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); + String result3 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", chooseFileFilter2).get(); + Assert.assertEquals("WorkBook1.cptx", result3); + + ChooseFileFilter chooseFileFilter3 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); + String result4 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter3).get(); + Assert.assertEquals("WorkBook1.cpt", result4); + + ChooseFileFilter chooseFileFilter5 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); + String result5 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter5).get(); + Assert.assertEquals("WorkBook1.cptx", result5); + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartCommonWizardPane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartCommonWizardPane.java index 6ff6e0639d..0e11e84132 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartCommonWizardPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartCommonWizardPane.java @@ -12,7 +12,7 @@ public abstract class ChartCommonWizardPane extends ChartWizardPane { return; } - populate(cc.getSelectedChartProvider()); + populate(cc.getSelectedChartProvider(ChartProvider.class)); } public abstract void populate(ChartProvider chart); diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java index 8233e68e80..19c6137858 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java @@ -123,7 +123,7 @@ public class ChartTypePane extends ChartCommonWizardPane { return; } - ChartProvider chart4Update = cc.getSelectedChartProvider(); + ChartProvider chart4Update = cc.getSelectedChartProvider(ChartProvider.class); if (chart4Update == null) { String plotID = this.chartIDs[mainTypeList.getSelectedIndex()]; ChartProvider chart = ChartTypeManager.getInstance().getCharts(plotID)[iconViewList.getSelectedIndex()]; diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java index e3d6a52101..2385cabd60 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java @@ -13,6 +13,8 @@ import com.fr.log.FineLoggerFactory; import com.fr.script.Calculator; import com.fr.stable.core.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; @@ -22,8 +24,6 @@ import java.awt.RenderingHints; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; -import java.util.ArrayList; -import java.util.List; /** * @author kunsnat E-mail:kunsnat@gmail.com @@ -236,7 +236,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene private void drawChart(Graphics2D g2d) { if (chartCollection4Design != null) { - BaseChartPainter painter = chartCollection4Design.createResultChartPainter(Calculator.createCalculator(), + BaseChartPainter painter = chartCollection4Design.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), WebChartIDInfo.createEmptyDesignerInfo(), chartWidth, chartHeight); int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); diff --git a/designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java index 61359d91b7..b8690f8df6 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java @@ -26,7 +26,7 @@ public abstract class AbstractChartDataPane extends if (collection == null) { return; } - AbstractChartWithData chart = collection.getSelectedChart(AbstractChartWithData.class); + AbstractChartWithData chart = collection.getSelectedChartProvider(AbstractChartWithData.class); if (chart == null) { return; } @@ -32,7 +32,7 @@ public abstract class AbstractOtherPane extends if (collection == null) { return; } - AbstractChartWithData chart = collection.getSelectedChart(AbstractChartWithData.class); + AbstractChartWithData chart = collection.getSelectedChartProvider(AbstractChartWithData.class); if (chart == null) { return; } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/MiddleChartPropertyPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/MiddleChartPropertyPane.java index 1b2a85668f..39832c3777 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/MiddleChartPropertyPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/MiddleChartPropertyPane.java @@ -6,6 +6,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.chart.BaseChartCollection; import com.fr.chart.chartattr.ChartCollection; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.designer.TargetComponent; import com.fr.design.gui.chart.BaseChartPropertyPane; @@ -14,11 +15,12 @@ import com.fr.design.gui.frpane.UITitlePanel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itabpane.TitleChangeListener; import com.fr.design.mainframe.chart.ChartEditPane; - import com.fr.stable.StableUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JComponent; +import java.awt.BorderLayout; public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ @@ -91,7 +93,7 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ * @param ePane 面板 */ public void populateChartPropertyPane(ChartCollection collection, TargetComponent ePane) { - addChartEditPane(collection.getSelectedChartProvider().getID()); + addChartEditPane(collection.getSelectedChartProvider(ChartProvider.class).getID()); setSupportCellData(true); this.container.setEPane(ePane); chartEditPane.populate(collection); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java index 5ecfa1071c..4ef5beffb1 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java @@ -111,7 +111,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 if (!ComparatorUtils.equals(collection, lastCollection)) { - VanChart vanChart = collection.getSelectedChart(VanChart.class); + VanChart vanChart = collection.getSelectedChartProvider(VanChart.class); if (vanChart != null) { //此处画图 vanChart.demoImgEvent(true); @@ -230,7 +230,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 return; } - ChartProvider chartProvider = collection.getSelectedChartProvider(); + ChartProvider chartProvider = collection.getSelectedChartProvider(ChartProvider.class); if (checkNeedsReLayout(chartProvider)) { String chartID = chartProvider.getID(); if ("WaferChipChart".equals(chartID) || "BoxPlotChart".equals(chartID)) { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index 880c1a7792..8877ed9dac 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -176,7 +176,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen * @return */ public ChartProvider getChangeStateNewChart() { - ChartProvider chart = editingCollection.getSelectedChartProvider(); + ChartProvider chart = editingCollection.getSelectedChartProvider(ChartProvider.class); String chartID = chart.getID(); String priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); return ChartTypeManager.getInstanceWithCheck().getFirstChart(priority); @@ -199,7 +199,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen } private boolean supportChange() { - return supportChangeConfigChartClassSet.contains(editingCollection.getSelectedChartProvider().getClass()); + return supportChangeConfigChartClassSet.contains(editingCollection.getSelectedChartProvider(ChartProvider.class).getClass()); } ActionListener configListener = new ActionListener() { @@ -354,9 +354,9 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen } private void checkConfigButtonVisible() { - addButton.setVisible(ChartTypeManager.enabledChart(editingCollection.getSelectedChartProvider().getID())); + addButton.setVisible(ChartTypeManager.enabledChart(editingCollection.getSelectedChartProvider(ChartProvider.class).getID())); //新建一个collection - if (editingCollection.getChartCount() == 1 && editingCollection.getSelectedChartProvider() != null) { + if (editingCollection.getChartCount() == 1 && editingCollection.getSelectedChartProvider(ChartProvider.class) != null) { //Chart 不支持图表切换 configButton.setVisible(supportChange()); } @@ -484,7 +484,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private void deleteAButton() { //先重构属性,在重构面板,否则面板在重构过程中,会重新将属性中的切换图表加到indexList中,导致面板无法删除 //记录改变前的plotID - String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChartProvider().getID(); + String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChartProvider(ChartProvider.class).getID(); if (editingCollection != null) { int count = editingCollection.getChartCount(); for (int i = 0; i < count; i++) { @@ -564,7 +564,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen if (isEnabled()) { noSelected(); //记录改变前的plotID - String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChartProvider().getID(); + String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChartProvider(ChartProvider.class).getID(); changeCollectionSelected(getButtonName()); setSelectedWithFireListener(true); fireSelectedChanged(); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index 77e75a69a1..3740e3e121 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -19,15 +19,15 @@ import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; /** * 图表 属性表, 类型选择 界面. @@ -208,7 +208,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ //处理办法:这边除了重构 下拉项选项和cardNames 还需要把cards重构下(不需要init pane,只需要我需要的拿出来就好了) private void relayout(ChartCollection collection){ //重构需要重构下拉框选项和cardNames - ChartProvider chart = collection.getSelectedChartProvider(); + ChartProvider chart = collection.getSelectedChartProvider(ChartProvider.class); String chartID = chart.getID(); String priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); boolean enabledChart = ChartTypeManager.enabledChart(chartID); @@ -294,7 +294,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ * @param collection */ public void reLayoutEditPane(String lastPlotID, ChartCollection collection){ - ChartProvider chart = collection.getSelectedChartProvider(); + ChartProvider chart = collection.getSelectedChartProvider(ChartProvider.class); String plotID = chart.getID(); boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); if (editPane != null && editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID))){ @@ -315,7 +315,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ public void populate(ChartCollection collection) { editingCollection = collection; - ChartProvider chart = collection.getSelectedChartProvider(); + ChartProvider chart = collection.getSelectedChartProvider(ChartProvider.class); this.remove(leftContentPane); initContentPane(); @@ -333,7 +333,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ public void update(ChartCollection collection) { editingCollection = collection; buttonPane.update(collection);// 内部操作时 已经做过处理. - ChartProvider chart = collection.getSelectedChartProvider(); + ChartProvider chart = collection.getSelectedChartProvider(ChartProvider.class); chartTypeComBox.updateBean(chart); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java index f12fe344e8..77409e4c02 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java @@ -88,7 +88,12 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { return ChartConstants.GIS_CHAER; } - protected String[] getTypeLayoutPath() { + @Override + public String getPlotID() { + return ChartConstants.GIS_CHAER; + } + + protected String[] getTypeLayoutPath() { return new String[]{"/com/fr/design/images/chart/GisMapPlot/layout/0.png", "/com/fr/design/images/chart/GisMapPlot/layout/1.png", }; @@ -157,7 +162,6 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { * 更新界面内容 */ public void populateBean(Chart chart) { - typeDemo.get(0).isPressing = true; GisMapPlot plot = (GisMapPlot) chart.getPlot(); if(plot.isGisType()){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java index b978d9355a..2e1056ae89 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java @@ -14,6 +14,8 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; +import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; +import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; @@ -21,6 +23,8 @@ import com.fr.van.chart.designer.other.zoom.ZoomPane; import com.fr.van.chart.designer.other.zoom.ZoomPaneWithOutMode; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; +import com.fr.van.chart.wordcloud.designer.data.WordCloudPlotReportDataContentPane; +import com.fr.van.chart.wordcloud.designer.data.WordCloudPlotTableDataContentPane; import com.fr.van.chart.wordcloud.designer.other.VanChartWordCloudConditionPane; import com.fr.van.chart.wordcloud.designer.style.VanChartWordCloudSeriesPane; import com.fr.van.chart.wordcloud.designer.type.VanChartWordCloudTypePane; @@ -63,6 +67,16 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa return "com/fr/design/images/form/toolbar/wordcloud.png"; } + @Override + public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { + return new WordCloudPlotReportDataContentPane(); + } + + @Override + public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { + return new WordCloudPlotTableDataContentPane(); + } + @Override public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { return new VanChartWordCloudSeriesPane(parent, plot); diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java index c7121f0e16..76eb602300 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java @@ -18,7 +18,9 @@ import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; import com.fr.stable.ArrayUtils; -import java.awt.*; +import java.awt.LayoutManager; +import java.awt.Rectangle; +import java.awt.Toolkit; import java.awt.event.MouseEvent; import java.util.ArrayList; @@ -175,36 +177,19 @@ public class SelectionModel { } private void pasteXWFitLayout() { - if (selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)) { - XLayoutContainer container = (XLayoutContainer) selection.getSelectedCreator(); - //tab布局编辑器内部左上角第一个坐标点 - int leftUpX = container.toData().getMargin().getLeft() + 1; - int leftUpY = container.toData().getMargin().getTop() + 1; - //选中第一个坐标点坐在的组件 - selection.setSelectedCreator((XCreator) container.getComponentAt(leftUpX, leftUpY)); - Rectangle rectangle = selection.getRelativeBounds(); - if (hasSelectedPasteSource()) { - selectedPaste(); - } else { - FormSelectionUtils.paste2Container(designer, container, clipboard, - rectangle.x + rectangle.width / 2, - rectangle.y + DELTA_X_Y); - } + //自适应布局编辑器内部左上角第一个坐标点 + int leftUpX = designer.getRootComponent().toData().getMargin().getLeft() + 1; + int leftUpY = designer.getRootComponent().toData().getMargin().getTop() + 1; + //选中第一个坐标点坐在的组件 + selection.setSelectedCreator((XCreator) designer.getRootComponent().getComponentAt(leftUpX, leftUpY)); + Rectangle rectangle = selection.getRelativeBounds(); + if (hasSelectedPasteSource()) { + selectedPaste(); } else { - //自适应布局编辑器内部左上角第一个坐标点 - int leftUpX = designer.getRootComponent().toData().getMargin().getLeft() + 1; - int leftUpY = designer.getRootComponent().toData().getMargin().getTop() + 1; - //选中第一个坐标点坐在的组件 - selection.setSelectedCreator((XCreator) designer.getRootComponent().getComponentAt(leftUpX, leftUpY)); - Rectangle rectangle = selection.getRelativeBounds(); - if (hasSelectedPasteSource()) { - selectedPaste(); - } else { - FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), - clipboard, - rectangle.x + rectangle.width / 2, - rectangle.y + DELTA_X_Y); - } + FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), + clipboard, + rectangle.x + rectangle.width / 2, + rectangle.y + DELTA_X_Y); } } @@ -497,4 +482,4 @@ public class SelectionModel { selection.setSelectedCreators(rebuildSelection); fireCreatorSelected(); } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java index dc555e5d14..5a7ae9817c 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java @@ -31,6 +31,7 @@ import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; import com.fr.general.act.TitlePacker; import com.fr.general.cardtag.TemplateStyle; +import com.fr.stable.ProductConstants; import com.fr.stable.unit.PT; import javax.swing.*; @@ -210,7 +211,7 @@ public class XCardSwitchButton extends XButton { private void deleteCard(XCardSwitchButton button, int index){ String titleName = button.getContentLabel().getText(); int value = JOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Confirm_Dialog_Content") + "“" + titleName + "”", - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_ConfirmDialog_Title"), JOptionPane.YES_NO_OPTION); + ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION); if (value != JOptionPane.OK_OPTION) { return; } @@ -352,7 +353,7 @@ public class XCardSwitchButton extends XButton { private void deleteTabLayout(SelectionModel selectionModel, FormDesigner designer){ String titleName = this.getContentLabel().getText(); int value = JOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Confirm_Dialog_Content") + "“" + titleName + "”", - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_ConfirmDialog_Title"),JOptionPane.YES_NO_OPTION); + ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION); if (value != JOptionPane.OK_OPTION) { return; } diff --git a/designer-form/src/main/java/com/fr/design/designer/properties/EventPropertyTable.java b/designer-form/src/main/java/com/fr/design/designer/properties/EventPropertyTable.java index 1592b0fd01..ec953b9da3 100644 --- a/designer-form/src/main/java/com/fr/design/designer/properties/EventPropertyTable.java +++ b/designer-form/src/main/java/com/fr/design/designer/properties/EventPropertyTable.java @@ -28,6 +28,7 @@ public class EventPropertyTable extends UIListControlPane { public EventPropertyTable(FormDesigner designer) { super(); + this.setNameListEditable(false); this.designer = designer; } diff --git a/designer-form/src/main/java/com/fr/design/form/mobile/FormMobileOthersPane.java b/designer-form/src/main/java/com/fr/design/form/mobile/FormMobileOthersPane.java index 60cc6d21f0..2e2b16997f 100644 --- a/designer-form/src/main/java/com/fr/design/form/mobile/FormMobileOthersPane.java +++ b/designer-form/src/main/java/com/fr/design/form/mobile/FormMobileOthersPane.java @@ -33,7 +33,7 @@ public class FormMobileOthersPane extends BasicBeanPane { contentPane.add(appearRefreshCheckPane, BorderLayout.WEST); promptWhenLeaveWithoutSubmitCheckPane = new MobileRadioCheckPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Prompt_When_Leave_Without_Submit")); contentPane.add(promptWhenLeaveWithoutSubmitCheckPane, BorderLayout.CENTER); - allowDoubleClickOrZoomCheckPane = new MobileRadioCheckPane(com.fr.design.i18n.Toolkit.i18nText("允许双击/双指缩放")); + allowDoubleClickOrZoomCheckPane = new MobileRadioCheckPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Attr_Allow_Zoom")); contentPane.add(allowDoubleClickOrZoomCheckPane, BorderLayout.EAST); borderPane.add(contentPane); this.add(borderPane); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java b/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java index 090969d348..abe0c97e86 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java @@ -8,9 +8,7 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.form.main.Form; import com.fr.form.main.WidgetGatherAdapter; import com.fr.form.ui.BaseChartEditor; -import com.fr.form.ui.DataControl; import com.fr.form.ui.ElementCaseEditor; -import com.fr.form.ui.MultiFileEditor; import com.fr.form.ui.Widget; import com.fr.script.Calculator; import com.fr.stable.ParameterProvider; @@ -74,7 +72,7 @@ public class FormModelAdapter extends DesignModelAdapter> @Override public void dealWith(Widget widget) { - if (widget instanceof DataControl || widget instanceof MultiFileEditor) { + if (widgetAccepted(widget)) { list.add(new WidgetName(widget.getWidgetName())); } } 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 8d223c2452..cbebbcba16 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 @@ -11,6 +11,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.cardlayout.XWCardTagLayout; +import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.Widget; @@ -264,12 +265,18 @@ public class FormSelection { * @param designer 设计界面组件 */ public void fixCreator(FormDesigner designer) { + int i = 0; for (XCreator creator : selection) { LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(designer, creator); if (layoutAdapter != null) { - creator.setBackupBound(backupBounds); + if (creator.acceptType(XWAbsoluteLayout.class) && recs.size() > i) { + creator.setBackupBound(recs.get(i)); + } else { + creator.setBackupBound(backupBounds); + } layoutAdapter.fix(creator); } + i++; } } @@ -317,6 +324,9 @@ public class FormSelection { clipBoard.reset(); for (XCreator root : selection) { + if(root.acceptType(XWTabFitLayout.class)){ + continue; + } try { XCreator creator = XCreatorUtils.createXCreator((Widget) root.toData().clone()); creator.setBounds(root.getBounds()); @@ -326,4 +336,4 @@ public class FormSelection { } } } -} \ No newline at end of file +} 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 6b8cbbe5d5..a37a1c4665 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 @@ -3,6 +3,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.PaperSize; import com.fr.base.Parameter; +import com.fr.base.extension.FileExtension; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignState; import com.fr.design.actions.FormMobileAttrAction; @@ -34,6 +35,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.xpane.FormHyperlinkGroupPane; import com.fr.design.gui.xpane.FormHyperlinkGroupPaneNoPop; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.form.FormECCompositeProvider; import com.fr.design.mainframe.form.FormECDesignerProvider; @@ -52,6 +54,8 @@ import com.fr.design.report.fit.menupane.ReportFitAttrAction; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.utils.gui.LayoutUtils; import com.fr.file.FILE; +import com.fr.file.FILEChooserPane; +import com.fr.file.filter.ChooseFileFilter; import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseProvider; import com.fr.form.main.Form; @@ -66,6 +70,7 @@ import com.fr.report.cell.cellattr.CellImage; import com.fr.report.worksheet.FormElementCase; import com.fr.stable.ArrayUtils; import com.fr.stable.Constants; +import com.fr.stable.ProductConstants; import com.fr.stable.bridge.StableFactory; import com.fr.web.controller.ViewRequestConstants; @@ -949,4 +954,10 @@ public class JForm extends JTemplate implements BaseJForm extends Tar // those that are interested in this event for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == SelectionListener.class) { - ((SelectionListener) listeners[i + 1]).selectionChanged(new SelectionEvent(this)); + ((SelectionListener) listeners[i + 1]).selectionChanged(new SelectionEvent(ElementCasePane.this)); } } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java index 52440d9e3d..62d1d4a3ea 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java @@ -9,6 +9,7 @@ import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.errorinfo.ErrorInfoUploader; import com.fr.design.mainframe.messagecollect.impl.FocusPointMessageUploader; +import com.fr.design.mainframe.messagecollect.solid.SolidCollector; import com.fr.design.mainframe.template.info.TemplateInfoCollector; import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; @@ -230,6 +231,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { service.schedule(new Runnable() { @Override public void run() { + SolidCollector.getInstance().sendToCloudCenterAndDeleteFile(); sendUserInfo(); FocusPointMessageUploader.getInstance().sendToCloudCenter(); TemplateInfoCollector.getInstance().sendTemplateInfo(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java index f93d473f6e..b68e49e168 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java @@ -3,6 +3,7 @@ */ package com.fr.design.mainframe; +import com.fr.file.FILEChooserPane; import com.fr.main.impl.WorkBook; import com.fr.report.poly.PolyWorkSheet; @@ -44,4 +45,8 @@ public class JPolyWorkBook extends JWorkBook { public void refreshEastPropertiesPane() { EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.POLY); } -} \ No newline at end of file + + protected void addExtraChooseFILEFilter(FILEChooserPane fileChooser) { + + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index f7e9ed7659..125cb4ccb4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.base.DynamicUnitList; import com.fr.base.Parameter; import com.fr.base.ScreenResolution; +import com.fr.base.extension.FileExtension; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignModelAdapter; import com.fr.design.ExtraDesignClassManager; @@ -34,12 +35,14 @@ import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; +import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.design.fun.PreviewProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIModeControlContainer; import com.fr.design.gui.imenu.UIMenuItem; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.cell.QuickEditorRegion; import com.fr.design.mainframe.template.info.JWorkBookProcessInfo; import com.fr.design.mainframe.template.info.TemplateProcessInfo; @@ -65,8 +68,10 @@ import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.write.submit.SmartInsertDBManipulationInWidgetEventPane; import com.fr.design.write.submit.SmartInsertDBManipulationPane; import com.fr.file.FILE; +import com.fr.file.FILEChooserPane; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; +import com.fr.file.filter.ChooseFileFilter; import com.fr.general.ComparatorUtils; import com.fr.general.ModuleContext; import com.fr.grid.Grid; @@ -90,6 +95,7 @@ import com.fr.report.poly.PolyWorkSheet; import com.fr.report.worksheet.WorkSheet; import com.fr.stable.ArrayUtils; import com.fr.stable.AssistUtils; +import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.module.Module; @@ -669,11 +675,13 @@ public class JWorkBook extends JTemplate { // Export - MenuDef MenuDef exportMenuDef = new MenuDef(KeySetUtils.EXPORT.getMenuName()); exportMenuDef.setIconPath("/com/fr/design/images/m_file/export.png"); + addShortCut(exportMenuDef, excelExportMenuDef); + return exportMenuDef; + } + protected void addShortCut(MenuDef exportMenuDef, MenuDef excelExportMenuDef) { exportMenuDef.addShortCut(excelExportMenuDef, new PDFExportAction(this), new WordExportAction(this), new SVGExportAction(this), new CSVExportAction(this), new TextExportAction(this), new EmbeddedExportExportAction(this)); - - return exportMenuDef; } /** @@ -1166,4 +1174,17 @@ public class JWorkBook extends JTemplate { public String route() { return ViewRequestConstants.REPORT_VIEW_PATH; } + + protected void addChooseFILEFilter(FILEChooserPane fileChooser) { + String appName = ProductConstants.APP_NAME; + fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPT, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); + addExtraChooseFILEFilter(fileChooser); + } + + protected void addExtraChooseFILEFilter(FILEChooserPane fileChooser){ + Set providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG); + for (ReportSupportedFileUIProvider provider : providers) { + provider.addChooseFileFilter(fileChooser, this.suffix()); + } + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java b/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java index 1e55d3c9b0..fff25486dc 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java @@ -7,14 +7,12 @@ import com.fr.design.DesignModelAdapter; import com.fr.design.bridge.DesignToolbarProvider; import com.fr.form.ui.Widget; import com.fr.main.impl.WorkBook; +import com.fr.main.impl.WorkBookHelper; import com.fr.main.parameter.ReportParameterAttr; -import com.fr.report.cell.CellElement; -import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.FloatElement; -import com.fr.report.elementcase.ElementCase; import com.fr.report.elementcase.TemplateElementCase; -import com.fr.report.report.Report; import com.fr.script.Calculator; +import com.fr.stable.Filter; import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; import com.fr.stable.bridge.StableFactory; @@ -30,6 +28,7 @@ import java.util.List; */ public class WorkBookModelAdapter extends DesignModelAdapter { + public WorkBookModelAdapter(JWorkBook jworkbook) { super(jworkbook); } @@ -115,27 +114,21 @@ public class WorkBookModelAdapter extends DesignModelAdapter getWidgetsName() { - List list = new ArrayList(); WorkBook wb = this.getBook(); - for (int i = 0, len = wb.getReportCount(); i < len; i++) { - Report report = wb.getReport(i); - Iterator it = report.iteratorOfElementCase(); - while (it.hasNext()) { - ElementCase ec = (ElementCase) it.next(); - Iterator cs = ec.cellIterator(); - while (cs.hasNext()) { - CellElement ce = (CellElement) cs.next(); - if (ce instanceof DefaultTemplateCellElement) { - Widget widget = ((DefaultTemplateCellElement) ce).getWidget(); - if (widget != null && StringUtils.isNotEmpty(widget.getWidgetName())) { - list.add(new WidgetName(widget.getWidgetName())); - } - } - } + return WorkBookHelper.listWidgetNamesInWorkBook(wb, new Filter() { + @Override + public boolean accept(Widget widget) { + return widgetAccepted(widget); } - } - return list; + }, new Filter() { + @Override + public boolean accept(Widget widget) { + //todo 这边有没有必要统一改成widgetAccepted?暂时不改,插件那边可能会有影响,因为插件有的控件并没有实现DataControl的 + return widget != null && StringUtils.isNotEmpty(widget.getWidgetName()); + } + }); } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java index 4e733c7b1d..9bfd729dd4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java @@ -37,6 +37,9 @@ public class ErrorInfo { this.uploadtime = dateToString(); } + public ErrorInfo() { + } + public String getUsername() { return username; } @@ -123,7 +126,7 @@ public class ErrorInfo { saveFileToCache(jo); } - private void saveFileToCache(JSONObject jo) { + public void saveFileToCache(JSONObject jo) { String content = jo.toString(); String fileName = UUID.randomUUID() + ErrorInfoUploader.SUFFIX; File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), ErrorInfoUploader.FOLDER_NAME, fileName)); diff --git a/designer-realize/src/main/java/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java b/designer-realize/src/main/java/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java index 349735ac0b..1dd75e1633 100644 --- a/designer-realize/src/main/java/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java @@ -69,6 +69,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane { soverlapRowStartPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Title_Start_Row_Form"))); repeatTitleRowPane = new RepeatRowPane(); soverlapRowStartPane.add(repeatTitleRowPane); + soverlapRowStartPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Row"))); return soverlapRowStartPane; } @@ -85,6 +86,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane { // 重复打印标题的结束列 repeatTitleColPane = new RepeatColPane(); soverlapColStartPane.add(repeatTitleColPane); + soverlapColStartPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Column"))); return soverlapColStartPane; } @@ -100,6 +102,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane { foverlapRowStartPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Finis_Start_Row_Form"))); repeatFinisRowPane = new RepeatRowPane(); foverlapRowStartPane.add(repeatFinisRowPane); + foverlapRowStartPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Row"))); return foverlapRowStartPane; } @@ -115,6 +118,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane { foverlapColStartPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Finis_Start_Column_Form"))); repeatFinisColPane = new RepeatColPane(); foverlapColStartPane.add(repeatFinisColPane); + foverlapColStartPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Column"))); return foverlapColStartPane; } diff --git a/designer-realize/src/main/java/com/fr/design/report/mobile/MobileOthersPane.java b/designer-realize/src/main/java/com/fr/design/report/mobile/MobileOthersPane.java index 4f88dcaef2..3948c26f3c 100644 --- a/designer-realize/src/main/java/com/fr/design/report/mobile/MobileOthersPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/mobile/MobileOthersPane.java @@ -32,7 +32,7 @@ public class MobileOthersPane extends BasicBeanPane { contentPane.setBorder(BorderFactory.createEmptyBorder(0, IntervalConstants.INTERVAL_L1, 0, 0)); appearRefreshCheckPane = new MobileRadioCheckPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Appear_Refresh")); contentPane.add(appearRefreshCheckPane, BorderLayout.WEST); - allowDoubleClickOrZoomCheckPane = new MobileRadioCheckPane(com.fr.design.i18n.Toolkit.i18nText("允许双击/双指缩放")); + allowDoubleClickOrZoomCheckPane = new MobileRadioCheckPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Attr_Allow_Zoom")); contentPane.add(allowDoubleClickOrZoomCheckPane, BorderLayout.CENTER); borderPane.add(contentPane); this.add(borderPane); diff --git a/designer-realize/src/main/java/com/fr/design/webattr/EventPane.java b/designer-realize/src/main/java/com/fr/design/webattr/EventPane.java index a4f1537106..525ee2863f 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/EventPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/EventPane.java @@ -168,7 +168,7 @@ public class EventPane extends BasicPane { return; } - int val = JOptionPane.showConfirmDialog(EventPane.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Are_You_Sure_To_Delete_The_Data") + "?", "Message", + int val = JOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(EventPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Are_You_Sure_To_Delete_The_Data") + "?", "Message", JOptionPane.YES_NO_OPTION); if (val != JOptionPane.YES_OPTION) { return; diff --git a/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java b/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java index d3aec5897c..6a3e0415d2 100644 --- a/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java @@ -5,6 +5,7 @@ import com.fr.design.RestartHelper; import com.fr.design.i18n.Toolkit; import com.fr.design.utils.DesignUtils; import com.fr.event.EventDispatcher; +import com.fr.file.TmpFileUtils; import com.fr.general.CloudCenter; import com.fr.general.GeneralContext; import com.fr.module.Activator; @@ -17,6 +18,8 @@ public class PreStartActivator extends Activator { @Override public void start() { + //清空临时文件 + TmpFileUtils.cleanUpInnerTmpFiles(); RestartHelper.deleteRecordFilesWhenStart(); //初始化 EventDispatcher.fire(ModuleEvent.MajorModuleStarting, Toolkit.i18nText("Fine-Design_Basic_Initializing"));