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 7f2aeeb781..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,14 +1,17 @@ package com.fr.design; 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; import com.fr.stable.ArrayUtils; -import com.fr.stable.OperatingSystem; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.workspace.WorkContext; +import javax.swing.*; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -16,8 +19,6 @@ import java.io.IOException; import java.io.RandomAccessFile; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; -import java.util.ArrayList; -import java.util.List; import java.util.Map; import java.util.Properties; @@ -30,7 +31,7 @@ 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 final OSBasedAction restartAction = new RestartAction(); /** * 把要删除的文件都记录到delete.properties中 @@ -143,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); + } + } + + + /** * 重启设计器并删除某些特定的文件 * @@ -168,11 +183,7 @@ public class RestartHelper { }catch (Exception e){ FineLoggerFactory.getLogger().error(e.getMessage(), e); } - if (OperatingSystem.isMacOS()) { - restartInMacOS(installHome, filesToBeDelete); - } else { - restartInWindows(installHome, filesToBeDelete); - } + restartAction.execute(filesToBeDelete); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } finally { @@ -186,28 +197,4 @@ public class RestartHelper { DesignerContext.getDesignerFrame().exit(); } } - - private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception { - ProcessBuilder builder = new ProcessBuilder(); - List commands = new ArrayList(); - commands.add("open"); - commands.add(installHome + File.separator + "bin" + File.separator + "restart.app"); - if (ArrayUtils.isNotEmpty(filesToBeDelete)) { - commands.add("--args"); - commands.add(StableUtils.join(filesToBeDelete, "+")); - } - builder.command(commands); - builder.start(); - } - - private static void restartInWindows(String installHome, String[] filesToBeDelete) throws Exception { - ProcessBuilder builder = new ProcessBuilder(); - List commands = new ArrayList(); - commands.add(installHome + File.separator + "bin" + File.separator + "restart.exe"); - if (ArrayUtils.isNotEmpty(filesToBeDelete)) { - commands.add(StableUtils.join(filesToBeDelete, "+")); - } - builder.command(commands); - builder.start(); - } } \ 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 27b246188b..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,5 +1,6 @@ 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; @@ -28,7 +29,7 @@ import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.common.VcsHelper; -import com.fr.design.update.push.DesignerPushUpdateManager; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.general.ComparatorUtils; @@ -133,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; @@ -194,11 +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); @@ -213,10 +208,15 @@ public class PreferencePane extends BasicPane { joinProductImproveCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Join_Product_Improve")); improvePane.add(joinProductImproveCheckBox); - if (DesignerPushUpdateManager.getInstance().isAutoPushUpdateSupported()) { + 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); @@ -258,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); @@ -302,15 +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 (FineClusterConfig.getInstance().isCluster()) { - gcEnableCheckBox.setEnabled(false); - gcButton.setEnabled(false); - } return gcControlPane; } @@ -668,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 { @@ -703,7 +702,6 @@ public class PreferencePane extends BasicPane { this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort())); - openDebugComboBox.setSelected(designerEnvManager.isOpenDebug()); useOptimizedUPMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseOptimizedUPM()); useUniverseDBMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseUniverseDBM()); @@ -773,8 +771,6 @@ public class PreferencePane extends BasicPane { designerEnvManager.setJettyServerPort(portEditor.getValue().intValue()); - designerEnvManager.setOpenDebug(openDebugComboBox.isSelected()); - designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected()); designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue()); designerEnvManager.setJoinProductImprove(this.joinProductImproveCheckBox.isSelected()); @@ -887,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); @@ -1050,7 +1046,7 @@ public class PreferencePane extends BasicPane { if (size > Math.pow(n, 2)) { return df.format(size / Math.pow(n, 2)) + "MB"; } - return new StringBuilder().append(df.format(size / n)).append("KB").toString(); + return df.format(size / n) + "KB"; } /** @@ -1066,3 +1062,4 @@ public class PreferencePane extends BasicPane { } } + diff --git a/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java b/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java index 76b11b2ff9..50ecd0ea6d 100644 --- a/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java @@ -1,24 +1,17 @@ package com.fr.design.actions.server; - -import com.fr.config.ServerPreferenceConfig; import com.fr.data.impl.Connection; import com.fr.design.actions.UpdateAction; -import com.fr.design.data.datapane.connect.ConnectionManagerPane; import com.fr.design.data.datapane.connect.ConnectionShowPane; import com.fr.design.data.datapane.connect.DatabaseConnectionPane; import com.fr.design.dialog.BasicDialog; -import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.NameInspector; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.DesignerFrame; import com.fr.design.menu.MenuKeySet; -import com.fr.design.dcm.UniversalDatabaseOpener; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; +import com.fr.design.os.impl.DatabaseDialogAction; import com.fr.file.ConnectionConfig; import com.fr.general.IOUtils; -import com.fr.transaction.CallBackAdaptor; -import com.fr.transaction.Configurations; -import com.fr.transaction.WorkerFacade; import javax.swing.*; import java.awt.event.ActionEvent; @@ -60,56 +53,10 @@ public class ConnectionListAction extends UpdateAction { * @param evt 事件 */ public void actionPerformed(ActionEvent evt) { - if (ServerPreferenceConfig.getInstance().isUseUniverseDBM()) { - UniversalDatabaseOpener.showUniverseDatabaseDialog(); - } else { - openDesignDatabaseManager(); - } + OSBasedAction osBasedAction = OSSupportCenter.getAction(DatabaseDialogAction.class); + osBasedAction.execute(); } - private void openDesignDatabaseManager() { - DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); - final ConnectionConfig datasourceManager = ConnectionConfig.getInstance(); - final ConnectionManagerPane databaseManagerPane = new ConnectionManagerPane() { - public void complete() { - ConnectionConfig connectionConfig = datasourceManager.mirror(); - populate(connectionConfig); - } - - protected void renameConnection(String oldName, String newName) { - datasourceManager.renameConnection(oldName, newName); - } - }; - final BasicDialog databaseListDialog = databaseManagerPane.showLargeWindow(designerFrame, null); - databaseListDialog.addDialogActionListener(new DialogActionAdapter() { - public void doOk() { - if (!databaseManagerPane.isNamePermitted()) { - databaseListDialog.setDoOKSucceed(false); - return; - } - Configurations.modify(new WorkerFacade(ConnectionConfig.class) { - @Override - public void run() { - databaseManagerPane.update(datasourceManager); - } - }.addCallBack(new CallBackAdaptor() { - @Override - public boolean beforeCommit() { - //如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面 - return doWithDatasourceManager(datasourceManager, databaseManagerPane, databaseListDialog); - } - - @Override - public void afterCommit() { - DesignerContext.getDesignerBean("databasename").refreshBeanElement(); - } - })); - } - }); - databaseListDialog.setVisible(true); - } - - /** * 更新datasourceManager * diff --git a/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java b/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java index 1b7d7bbc47..d000dbbbb0 100644 --- a/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java @@ -1,11 +1,11 @@ package com.fr.design.actions.server; -import com.fr.config.ServerPreferenceConfig; import com.fr.design.actions.UpdateAction; -import com.fr.design.extra.WebViewDlgHelper; import com.fr.design.menu.MenuKeySet; -import com.fr.design.upm.UpmFinder; +import com.fr.design.os.impl.PMDialogAction; import com.fr.general.IOUtils; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; import javax.swing.*; import java.awt.event.ActionEvent; @@ -16,22 +16,17 @@ import java.awt.event.ActionEvent; * @since 8.0 */ public class PluginManagerAction extends UpdateAction { - public PluginManagerAction() { this.setMenuKeySet(PLUGIN_MANAGER); this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/server/plugin.png")); } - @Override public void actionPerformed(ActionEvent e) { // 可以启用新版本的插件商店(使用JxBrowser作为容器) - if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM()) { - UpmFinder.showUPMDialog(); - } else { - WebViewDlgHelper.createPluginDialog(); - } + OSBasedAction osBasedAction = OSSupportCenter.getAction(PMDialogAction.class); + osBasedAction.execute(); } public static final MenuKeySet PLUGIN_MANAGER = new MenuKeySet() { 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 44de37ea82..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 @@ -2,6 +2,7 @@ package com.fr.design.data; import com.fr.base.StoreProcedureParameter; import com.fr.base.TableData; +import com.fr.concurrent.NamedThreadFactory; import com.fr.data.TableDataSource; import com.fr.data.TableDataSourceTailor; import com.fr.data.core.DataCoreXmlUtils; @@ -30,12 +31,14 @@ import com.fr.general.ComparatorUtils; import com.fr.general.data.DataModel; import com.fr.general.data.TableDataException; import com.fr.log.FineLoggerFactory; +import com.fr.module.ModuleContext; import com.fr.script.Calculator; import com.fr.stable.ArrayUtils; 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; @@ -48,8 +51,8 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Timer; -import java.util.TimerTask; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; /** * 设计器管理操作数据集的类: @@ -420,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()); @@ -444,11 +447,18 @@ public abstract class DesignTableDataManager { } catch (Exception e) { throw new TableDataException(e.getMessage(), e); } finally { - new Timer().schedule(new TimerTask() { + ScheduledExecutorService scheduledExecutorService = ModuleContext + .getExecutor() + .newSingleThreadScheduledExecutor(new NamedThreadFactory("")); + scheduledExecutorService.schedule(new Runnable() { + @Override public void run() { - loadingBar.close(); + if (loadingBar != null) { + loadingBar.close(); + } } - }, 100); + }, 100, TimeUnit.MILLISECONDS); + scheduledExecutorService.shutdown(); } } @@ -513,6 +523,7 @@ public abstract class DesignTableDataManager { if (inParameters.length > 0 && !ComparatorUtils.equals(threadLocal.get(), NO_PARAMETER)) {// 检查Parameter. final ParameterInputPane pPane = new ParameterInputPane(inParameters); pPane.showSmallWindow(DesignerContext.getDesignerFrame(), 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 e553f9101d..28ac24e712 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 @@ -443,6 +443,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); } } @@ -466,7 +468,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/ConnectionTableProcedurePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java index f6f258285d..4b4d668666 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java @@ -98,7 +98,7 @@ public class ConnectionTableProcedurePane extends BasicPane { } protected void addKeyMonitor() { - + //do nothing } protected JPanel createCheckBoxgroupPane() { @@ -137,7 +137,7 @@ public class ConnectionTableProcedurePane extends BasicPane { /** * 给 itemComboBox 加上 itemListener - * + * * @param itemListener */ public void addItemListener(ItemListener itemListener) { @@ -214,7 +214,7 @@ public class ConnectionTableProcedurePane extends BasicPane { public static interface DoubleClickSelectedNodeOnTreeListener { /** * 处理双击事件 - * + * * @param target */ public void actionPerformed(TableProcedure target); 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/AutoStoreProcedureTableModel.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/AutoStoreProcedureTableModel.java index 30421fd949..3336596591 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/AutoStoreProcedureTableModel.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/AutoStoreProcedureTableModel.java @@ -38,6 +38,7 @@ public class AutoStoreProcedureTableModel extends StoreProcedureTableModel { this.setDefaultEditor(ParameterTableModel.ParameterEditor.class, new ParameterTableModel().new ParameterEditor()); this.setDefaultRenderer(StoreProcedureParameterValueEditor.class, new ProcedureParameterValueRenderer()); } + @Override public boolean isCellEditable(int row, int col) { if (ComparatorUtils.equals(getValueAt(row, col -1), "OUT")) { return false; @@ -48,6 +49,7 @@ public class AutoStoreProcedureTableModel extends StoreProcedureTableModel { return false; } + @Override public boolean shouldResponseDoubleClickAction () { return false; } @@ -77,15 +79,16 @@ public class AutoStoreProcedureTableModel extends StoreProcedureTableModel { }, 100); } + @Override public void popupMenuCanceled(PopupMenuEvent e) { - + //do nothing } }); this.addCellEditorListener(new CellEditorListener() { @Override public void editingCanceled(ChangeEvent e) { - + //do nothing } @Override @@ -147,6 +150,7 @@ public class AutoStoreProcedureTableModel extends StoreProcedureTableModel { editor = ValueEditorPaneFactory.createStoreProcedValueEditorPane(); } + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { editor.setCurrentEditor(0); editor.populate(value); diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ClassTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ClassTableDataPane.java index 7cd8dec3e8..871b762b98 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ClassTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ClassTableDataPane.java @@ -124,6 +124,7 @@ public class ClassTableDataPane extends AbstractTableDataPane { this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); } + @Override public void actionPerformed(ActionEvent e) { java.util.List oldParas = editorPane.update(); oldParas.add(new Parameter()); @@ -132,6 +133,7 @@ public class ClassTableDataPane extends AbstractTableDataPane { @Override public void checkEnabled() { + //do nothing } } private class RemoveParaAction extends UITableEditAction { @@ -149,6 +151,7 @@ public class ClassTableDataPane extends AbstractTableDataPane { @Override public void checkEnabled() { + //do nothing } } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/CustomDictModel.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/CustomDictModel.java index fdf44df23e..3d9fbad2ad 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/CustomDictModel.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/CustomDictModel.java @@ -1,22 +1,21 @@ package com.fr.design.data.tabledata.tabledatapane; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; +import com.fr.design.gui.itableeditorpane.ActionStyle; +import com.fr.design.gui.itableeditorpane.UIArrayTableModel; +import com.fr.design.gui.itableeditorpane.UITableEditAction; +import com.fr.design.gui.itableeditorpane.UITableModelAdapter; +import com.fr.design.gui.itextfield.UITextField; import javax.swing.AbstractCellEditor; import javax.swing.JTable; import javax.swing.event.CellEditorListener; import javax.swing.event.ChangeEvent; import javax.swing.table.TableCellEditor; - -import com.fr.design.gui.itableeditorpane.ActionStyle; -import com.fr.design.gui.itableeditorpane.UIArrayTableModel; -import com.fr.design.gui.itableeditorpane.UITableEditAction; -import com.fr.design.gui.itableeditorpane.UITableModelAdapter; -import com.fr.design.gui.itextfield.UITextField; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; public class CustomDictModel extends UITableModelAdapter implements ActionStyle { /** @@ -34,11 +33,13 @@ public class CustomDictModel extends UITableModelAdapter implements Ac this.setDefaultEditor(ParameterEditor.class, new ParameterEditor()); } + @Override public Object getValueAt(int row, int column) { Object[] os = this.getList().get(row); return os[column]; } + @Override public void setValueAt(Object value, int row, int column) { Object[] os = this.getList().get(row); os[column] = value; @@ -104,7 +105,7 @@ public class CustomDictModel extends UITableModelAdapter implements Ac @Override public void editingCanceled(ChangeEvent e) { - + //do nothing } @Override diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index 44b87cad60..e7be5bf338 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -101,10 +101,10 @@ public class DBTableDataPane extends AbstractTableDataPane { @Override protected void addKeyMonitor() { searchField.addKeyListener(new KeyListener() { - + @Override public void keyTyped(KeyEvent e) { - + //do nothing } @Override @@ -117,7 +117,7 @@ public class DBTableDataPane extends AbstractTableDataPane { @Override public void keyReleased(KeyEvent e) { - + //do nothing } }); } 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..947ac15aba 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; @@ -521,6 +521,7 @@ public class FileTableDataPane extends AbstractTableDataPane { @Override public void checkEnabled() { + //do nothing } } @@ -832,7 +833,7 @@ public class FileTableDataPane extends AbstractTableDataPane { } private class XMLNodeTree extends JTree { - private DefaultTreeModel treeModel; + private DefaultTreeModel xmlTreeModel; private DefaultTreeModel waitTreeModel = null; @@ -854,7 +855,7 @@ public class FileTableDataPane extends AbstractTableDataPane { private MouseListener treeMouseListener = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - if (XMLNodeTree.this.getModel() != treeModel) { + if (XMLNodeTree.this.getModel() != xmlTreeModel) { return; } int selRow = XMLNodeTree.this.getRowForLocation(e.getX(), e.getY()); @@ -891,7 +892,7 @@ public class FileTableDataPane extends AbstractTableDataPane { } public DefaultTreeModel getTreeModel() { - return treeModel; + return xmlTreeModel; } //防止界面卡死。 @@ -908,7 +909,7 @@ public class FileTableDataPane extends AbstractTableDataPane { //wikky:为满足706设计时对不合法的xml文件(有多个根节点)的处理,把拿到的InputStream强制在最外层添加作为唯一根节点而将文件转换为合法的xml。 private void initData() { params = getEditorPaneParameter(); // 生成tree结构放哪儿呢?放这里感觉不对撒 - treeModel = null; + xmlTreeModel = null; selectedNode = null; xmlColumnsList.clear(); DataSource dataSource = null; @@ -949,17 +950,17 @@ public class FileTableDataPane extends AbstractTableDataPane { FineLoggerFactory.getLogger().error(e.getMessage(), e); loadedTreeModel(); } - if (treeModel == null) { + if (xmlTreeModel == null) { FineLoggerFactory.getLogger().info("The file is wrong or bad, can not create the XMLReader."); return; } - if (treeModel.getChildCount(treeModel.getRoot()) == 1) { - treeModel = new DefaultTreeModel((ExpandMutableTreeNode) treeModel.getChild(treeModel.getRoot(), 0)); + if (xmlTreeModel.getChildCount(xmlTreeModel.getRoot()) == 1) { + xmlTreeModel = new DefaultTreeModel((ExpandMutableTreeNode) xmlTreeModel.getChild(xmlTreeModel.getRoot(), 0)); } else { - ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); + ExpandMutableTreeNode root = (ExpandMutableTreeNode) xmlTreeModel.getRoot(); root.setUserObject(StringUtils.EMPTY); } - this.setModel(treeModel); + this.setModel(xmlTreeModel); } private void loadedTreeModel() { @@ -1011,7 +1012,7 @@ public class FileTableDataPane extends AbstractTableDataPane { } currentNode = new ExpandMutableTreeNode(nodeName); if (layer == 0) { - treeModel = new DefaultTreeModel(currentNode); + xmlTreeModel = new DefaultTreeModel(currentNode); } else { boolean conflict = false; for (int i = 0; i < parentNode.getChildCount(); i++) { diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java index 4a5b33033a..2cf170c55e 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java @@ -144,12 +144,14 @@ public class MultiTDTableDataPane extends AbstractTableDataPane imp } populateWorker = new SwingWorker() { + @Override protected Void doInBackground() throws Exception { try { storeProcedureContext.setText(StringUtils.EMPTY); @@ -204,6 +205,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp return null; } + @Override public void done() { editorPane.populate(storeprocedure.getParameters()); } @@ -218,6 +220,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp * * @param listener 监听器 */ + @Override public void addStoreProcedureWorkerListener(StoreProcedureWorkerListener listener) { this.storeProcedureWorkerListener = listener; @@ -227,6 +230,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp /** * 去除存储过程监听器 */ + @Override public void removeStoreProcedureWorkerListener() { this.storeProcedureWorkerListener = null; @@ -264,6 +268,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp } updateWorker = new SwingWorker() { + @Override protected Void doInBackground() throws Exception { DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER); sp.setCalculating(true); @@ -271,6 +276,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp return null; } + @Override public void done() { DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER); sp.setCalculating(false); @@ -328,6 +334,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp /** * 响应数据集改变 */ + @Override public void fireDSChanged() { fireDSChanged(new HashMap()); } @@ -337,6 +344,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp * * @param map 改变的map */ + @Override public void fireDSChanged(Map map) { DesignTableDataManager.fireDSChanged(map); } @@ -348,6 +356,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); } + @Override public void actionPerformed(ActionEvent evt) { StoreProcedure sp = updateBeanWithOutExecute(); StoreProcedureDataWrapper storeProcedureDataWrappe = new StoreProcedureDataWrapper(sp, StringUtils.EMPTY, queryText.getText()); @@ -361,12 +370,14 @@ public class ProcedureDataPane extends AbstractTableDataPane imp this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); } + @Override public void actionPerformed(ActionEvent e) { refresh(); } @Override public void checkEnabled() { + //do nothing } } } diff --git a/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseDialog.java b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseDialog.java index 1a01a8641b..f035d7e418 100644 --- a/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseDialog.java +++ b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseDialog.java @@ -27,6 +27,6 @@ public class UniversalDatabaseDialog extends UIDialog { @Override public void checkValid() throws Exception { - + //do nothing } } diff --git a/designer-base/src/main/java/com/fr/design/designer/EditingState.java b/designer-base/src/main/java/com/fr/design/designer/EditingState.java index 3f4fdf6f05..8bd46d4bdb 100644 --- a/designer-base/src/main/java/com/fr/design/designer/EditingState.java +++ b/designer-base/src/main/java/com/fr/design/designer/EditingState.java @@ -7,6 +7,7 @@ public interface EditingState { @Override public void revert() { + //do nothing } }; diff --git a/designer-base/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptor.java b/designer-base/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptor.java index e4729f0709..e2470875d4 100644 --- a/designer-base/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptor.java +++ b/designer-base/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptor.java @@ -4,7 +4,7 @@ package com.fr.design.designer.creator; import com.fr.stable.StringUtils; -import com.fr.stable.core.PropertyChangeAdapter; +import com.fr.stable.core.PropertyChangeListener; import java.beans.IntrospectionException; import java.beans.PropertyDescriptor; @@ -17,7 +17,7 @@ public final class CRPropertyDescriptor extends PropertyDescriptor { public static final String RENDERER = "renderer"; private boolean isSubProperty = false; - private PropertyChangeAdapter l; + private PropertyChangeListener l; public CRPropertyDescriptor(String name, Class beanClass) throws IntrospectionException { super(name, beanClass); @@ -35,7 +35,7 @@ public final class CRPropertyDescriptor extends PropertyDescriptor { return this; } - public CRPropertyDescriptor setPropertyChangeListener(PropertyChangeAdapter l) { + public CRPropertyDescriptor setPropertyChangeListener(PropertyChangeListener l) { this.l = l; return this; } diff --git a/designer-base/src/main/java/com/fr/design/dialog/BasicScrollPane.java b/designer-base/src/main/java/com/fr/design/dialog/BasicScrollPane.java index d67b05d268..0255748979 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/BasicScrollPane.java +++ b/designer-base/src/main/java/com/fr/design/dialog/BasicScrollPane.java @@ -121,12 +121,12 @@ public abstract class BasicScrollPane extends BasicBeanPane{ @Override public void addLayoutComponent(String name, Component comp) { - + //do nothing } @Override public void removeLayoutComponent(Component comp) { - + //do nothing } @Override diff --git a/designer-base/src/main/java/com/fr/design/dialog/JWizardDialog.java b/designer-base/src/main/java/com/fr/design/dialog/JWizardDialog.java index 95894bd014..891e1bf757 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/JWizardDialog.java +++ b/designer-base/src/main/java/com/fr/design/dialog/JWizardDialog.java @@ -363,5 +363,6 @@ public class JWizardDialog extends BasicDialog { @Override public void checkValid() throws Exception { + //do nothing } } diff --git a/designer-base/src/main/java/com/fr/design/dialog/JWizardPanel.java b/designer-base/src/main/java/com/fr/design/dialog/JWizardPanel.java index ce3a2f9da6..c4762f2557 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/JWizardPanel.java +++ b/designer-base/src/main/java/com/fr/design/dialog/JWizardPanel.java @@ -168,7 +168,7 @@ public class JWizardPanel extends BasicPane { public void addNotify() { if (firstNotify) { Font font = stepTitleLabel.getFont(); - font = font.deriveFont(Font.BOLD, font.getSize() * 14 / 10.0F); + font = font.deriveFont(Font.BOLD, (float) (font.getSize() * 14 / 10.0D)); stepTitleLabel.setFont(font); firstNotify = false; } diff --git a/designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java b/designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java index 9258ce589c..80c545e922 100644 --- a/designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java +++ b/designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java @@ -1,18 +1,17 @@ package com.fr.design.editor.editor; -import java.awt.BorderLayout; -import java.awt.Component; - -import javax.swing.JList; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; - import com.fr.design.DesignModelAdapter; -import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.icombobox.FilterComboBox; +import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.stable.js.WidgetName; +import javax.swing.JList; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; +import java.awt.BorderLayout; +import java.awt.Component; + /** * the editor to edit WidgetName * @@ -43,12 +42,12 @@ public class WidgetNameEditor extends Editor { @Override public void popupMenuCanceled(PopupMenuEvent e) { - + //do nothing } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - + //do nothing } @Override diff --git a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java index efba8a2dfa..19b0857818 100644 --- a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java @@ -64,7 +64,9 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { writer.attr("path", path); } + @Override + @SuppressWarnings("squid:S2975") public Object clone() throws CloneNotSupportedException { LocalDesignerWorkspaceInfo object = (LocalDesignerWorkspaceInfo)super.clone(); diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index ffc80cb089..08477c6005 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -79,6 +79,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { } @Override + @SuppressWarnings("squid:S2975") public Object clone() throws CloneNotSupportedException { RemoteDesignerWorkspaceInfo object = (RemoteDesignerWorkspaceInfo) super.clone(); diff --git a/designer-base/src/main/java/com/fr/design/extra/AppStoreBuilder.java b/designer-base/src/main/java/com/fr/design/extra/AppStoreBuilder.java index ba8950ec2b..5599c75535 100644 --- a/designer-base/src/main/java/com/fr/design/extra/AppStoreBuilder.java +++ b/designer-base/src/main/java/com/fr/design/extra/AppStoreBuilder.java @@ -10,10 +10,10 @@ package com.fr.design.extra; public class AppStoreBuilder { public void checkStoreJavaSciptVersion() { - + //do nothing } public void updateStoreJavaScript() { - + //do nothing } } diff --git a/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java b/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java index 33983baf21..42791ad522 100644 --- a/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java +++ b/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java @@ -4,12 +4,8 @@ import com.fr.design.dialog.UIDialog; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.StableUtils; -import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dialog; -import java.awt.Dimension; -import java.awt.Frame; +import javax.swing.*; +import java.awt.*; /** * Created by vito on 2017/5/5. @@ -41,5 +37,6 @@ public class LoginDialog extends UIDialog { @Override public void checkValid() throws Exception { + // do nothing } } diff --git a/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java b/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java index 50add423f4..471e25109a 100644 --- a/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java +++ b/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java @@ -14,10 +14,8 @@ import javafx.concurrent.Task; import javafx.scene.web.WebEngine; import netscape.javascript.JSObject; -import javax.swing.JDialog; -import javax.swing.SwingUtilities; -import java.awt.Color; -import java.awt.Desktop; +import javax.swing.*; +import java.awt.*; import java.net.URI; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -221,5 +219,6 @@ public class LoginWebBridge { } public void openUrlAtLocalWebBrowser(WebEngine eng, String url) { + // do nothing } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginAbstractLoadingViewPane.java b/designer-base/src/main/java/com/fr/design/extra/PluginAbstractLoadingViewPane.java index 0eb1144665..3f06ffb9cf 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginAbstractLoadingViewPane.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginAbstractLoadingViewPane.java @@ -4,7 +4,6 @@ import com.fr.base.BaseUtils; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.ilable.UILabel; - import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; @@ -88,7 +87,7 @@ public abstract class PluginAbstractLoadingViewPane extends PluginAbstract @Override public void pressInstallButton() { - + // do nothing } @Override diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginControlPane.java b/designer-base/src/main/java/com/fr/design/extra/PluginControlPane.java index e5b4feba28..312d833471 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginControlPane.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginControlPane.java @@ -7,7 +7,6 @@ import com.fr.design.gui.ilist.UIList; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.IOUtils; - import com.fr.plugin.context.PluginMarker; import com.fr.plugin.license.Licensed; import com.fr.plugin.manage.PluginManager; @@ -23,7 +22,7 @@ import javax.swing.event.DocumentListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.*; -import java.util.*; +import java.util.ArrayList; import java.util.List; /** @@ -155,7 +154,7 @@ public class PluginControlPane extends BasicPane { PluginManager.getController().uninstall(PluginMarker.create(id, version), true, new PluginTaskCallback() { @Override public void done(PluginTaskResult result) { - + // do nothing } }); } diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginFromStorePane.java b/designer-base/src/main/java/com/fr/design/extra/PluginFromStorePane.java index 115cc87dc1..83ee0a16fb 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginFromStorePane.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginFromStorePane.java @@ -13,11 +13,7 @@ import com.fr.plugin.manage.control.ProgressCallback; import com.fr.plugin.view.PluginView; import com.fr.stable.StringUtils; -import javax.swing.JComponent; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.SwingConstants; +import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.File; import java.util.List; @@ -98,7 +94,7 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane config; private WebEngine webEngine; @@ -94,10 +94,10 @@ public class PluginWebBridge { * @return 配置信息 */ public String getRunConfig() { - if (action != null) { + if (actions != null) { JSONObject jsonObject = new JSONObject(); try { - jsonObject.put(ACTION, action.getContext()); + jsonObject.put(ACTION, actions.getContext()); Set keySet = config.keySet(); for (String key : keySet) { jsonObject.put(key, config.get(key).toString()); @@ -117,7 +117,7 @@ public class PluginWebBridge { * @param config 参数 */ public void setRunConfig(ACTIONS action, Map config) { - this.action = action; + this.actions = action; this.config = config; } @@ -125,7 +125,7 @@ public class PluginWebBridge { * 清楚打开动作 */ public void clearRunConfig() { - this.action = null; + this.actions = null; this.config = null; } diff --git a/designer-base/src/main/java/com/fr/design/extra/QQLoginDialog.java b/designer-base/src/main/java/com/fr/design/extra/QQLoginDialog.java index 4773aff689..3ba60054f2 100644 --- a/designer-base/src/main/java/com/fr/design/extra/QQLoginDialog.java +++ b/designer-base/src/main/java/com/fr/design/extra/QQLoginDialog.java @@ -3,7 +3,6 @@ package com.fr.design.extra; import com.fr.design.dialog.UIDialog; import com.fr.design.utils.gui.GUICoreUtils; - import javax.swing.*; import java.awt.*; @@ -27,6 +26,7 @@ public class QQLoginDialog extends UIDialog { @Override public void checkValid() throws Exception { + // do nothing } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java b/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java index e2fb97b627..72fa6149b6 100644 --- a/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java +++ b/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java @@ -29,5 +29,6 @@ public class ShopDialog extends UIDialog { @Override public void checkValid() throws Exception { + // do nothing } } diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index 5a722239c6..e0a3dd5479 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -21,26 +21,9 @@ import com.fr.third.javax.annotation.Nonnull; import com.fr.workspace.WorkContext; import com.fr.workspace.server.lock.TplOperator; -import javax.swing.BorderFactory; -import javax.swing.ButtonModel; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JSeparator; +import javax.swing.*; import javax.swing.plaf.basic.BasicMenuItemUI; -import java.awt.AWTEvent; -import java.awt.AlphaComposite; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.GradientPaint; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; +import java.awt.*; import java.awt.event.AWTEventListener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -398,8 +381,8 @@ public class MutilTempalteTabPane extends JComponent { //画下面的那条线 if (templateStartX < maxWidth) { GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, 2); - generalPath.moveTo((float) templateStartX, getHeight() - 1.0F); - generalPath.lineTo((float) maxWidth, getHeight() - 1.0F); + generalPath.moveTo((float) templateStartX, (float) (getHeight() - 1.0D)); + generalPath.lineTo((float) maxWidth, (float) (getHeight() - 1.0D)); g2d.fill(generalPath); //TODO hzzz delete // g2d.setPaint(UIConstants.LINE_COLOR); @@ -409,7 +392,7 @@ public class MutilTempalteTabPane extends JComponent { private void paintDefaultBackground(Graphics2D g2d) { //画默认背景 - g2d.setPaint(new GradientPaint(1, 1, UIConstants.TEMPLATE_TAB_PANE_BACKGROUND, 1, getHeight() - 1.0F, UIConstants.TEMPLATE_TAB_PANE_BACKGROUND)); + g2d.setPaint(new GradientPaint(1, 1, UIConstants.TEMPLATE_TAB_PANE_BACKGROUND, 1, (float) (getHeight() - 1.0D), UIConstants.TEMPLATE_TAB_PANE_BACKGROUND)); g2d.fillRect(0, 0, getWidth(), getHeight()); } @@ -535,7 +518,7 @@ public class MutilTempalteTabPane extends JComponent { double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX}; double[] y = {1, getHeight() + 1, getHeight() + 1, 1, 1}; RoundRectangle2D.Double rect1 = new RoundRectangle2D.Double(templateStartX, 1, this.getWidth(), this.getHeight(), 7, 7); - g2d.setPaint(new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, getHeight() - 1.0F, UIConstants.SELECT_TAB)); + g2d.setPaint(new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, (float) (getHeight() - 1.0D), UIConstants.SELECT_TAB)); //选了30度和60度的特殊角度的x,y作为经过的两个点的坐标 double specialLocation1 = 2.5; double specialLocation2 = 4.330127; @@ -590,9 +573,9 @@ public class MutilTempalteTabPane extends JComponent { double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX}; double[] y = {-1, getHeight() - 1, getHeight() - 1, -1, -1}; if (selfIndex == mouseOveredIndex) { - g2d.setPaint(new GradientPaint(1, 1, UIConstants.HOVER_BLUE, 1, getHeight() - 1.0F, UIConstants.HOVER_BLUE)); + g2d.setPaint(new GradientPaint(1, 1, UIConstants.HOVER_BLUE, 1, (float) (getHeight() - 1.0D), UIConstants.HOVER_BLUE)); } else { - g2d.setPaint(new GradientPaint(1, 1, UIConstants.SHADOW_GREY, 1, getHeight() - 1.0F, UIConstants.SHADOW_GREY)); + g2d.setPaint(new GradientPaint(1, 1, UIConstants.SHADOW_GREY, 1, (float) (getHeight() - 1.0D), UIConstants.SHADOW_GREY)); } @@ -854,7 +837,7 @@ public class MutilTempalteTabPane extends JComponent { */ @Override public void mouseEntered(MouseEvent e) { - + // do nothing } /** @@ -877,6 +860,7 @@ public class MutilTempalteTabPane extends JComponent { */ @Override public void mouseReleased(MouseEvent e) { + // do nothing } /** @@ -886,6 +870,7 @@ public class MutilTempalteTabPane extends JComponent { */ @Override public void mouseClicked(MouseEvent e) { + // do nothing } /** @@ -957,6 +942,7 @@ public class MutilTempalteTabPane extends JComponent { */ @Override public void mouseDragged(MouseEvent e) { + // do nothing } /** 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..c3b8d3e4d5 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) { @@ -128,7 +135,7 @@ public class NodeAuthProcessor { * @param fileNode file nodes * @return 带权限信息的文件节点 */ - public boolean fixFileNodeAuth(FileNode fileNode) { + public boolean checkFileNodeAuth(FileNode fileNode) { boolean isLocal = WorkContext.getCurrent().isLocal(); boolean isRoot = WorkContext.getCurrent().isRoot(); diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java index 2cf6efa910..c4433ab804 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java @@ -27,17 +27,7 @@ import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.script.Expression; -import javax.swing.BorderFactory; -import javax.swing.DefaultListCellRenderer; -import javax.swing.DefaultListModel; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JList; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JTree; -import javax.swing.SwingUtilities; +import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.event.TreeSelectionEvent; @@ -47,10 +37,7 @@ import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.MutableTreeNode; import javax.swing.tree.TreePath; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; @@ -148,10 +135,12 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { keyWordTextField.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { + //do nothing } @Override public void keyReleased(KeyEvent e) { + //do nothing } @Override @@ -236,7 +225,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { protected void extendCheckBoxPane(JPanel checkBoxPane) { - + // do nothing } private void configFormulaArea() { @@ -412,6 +401,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { @Override public void keyTyped(KeyEvent e) { + // do nothing } protected void search(String keyWord, boolean findDescription) { 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/date/UICalendarPanel.java b/designer-base/src/main/java/com/fr/design/gui/date/UICalendarPanel.java index c97b671dec..c21b740c43 100644 --- a/designer-base/src/main/java/com/fr/design/gui/date/UICalendarPanel.java +++ b/designer-base/src/main/java/com/fr/design/gui/date/UICalendarPanel.java @@ -437,18 +437,18 @@ public class UICalendarPanel extends JPanel { }; } - protected EventListenerList listenerList = new EventListenerList(); + protected EventListenerList eventlistenerList = new EventListenerList(); public void addDateChangeListener(ChangeListener l) { - listenerList.add(ChangeListener.class, l); + eventlistenerList.add(ChangeListener.class, l); } public void removeDateChangeListener(ChangeListener l) { - listenerList.remove(ChangeListener.class, l); + eventlistenerList.remove(ChangeListener.class, l); } protected void fireDateChanged(ChangeEvent e) { - Object[] listeners = listenerList.getListenerList(); + Object[] listeners = eventlistenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ChangeListener.class) { ((ChangeListener) listeners[i + 1]).stateChanged(e); 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/frpane/UnitInputPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java index 798b79af08..bab3e8851c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java @@ -133,14 +133,17 @@ public abstract class UnitInputPane extends BasicPane { @Override public void keyTyped(KeyEvent arg0) { + // 敲击键盘,发生在按键按下后,按键放开前 } @Override public void keyReleased(KeyEvent arg0) { + // 松开按键时 } @Override public void keyPressed(KeyEvent arg0) { + // 按下按键时 changed = true; } }; @@ -149,23 +152,28 @@ public abstract class UnitInputPane extends BasicPane { @Override public void mouseReleased(MouseEvent arg0) { + // 鼠标按键在组件上释放时 } @Override public void mousePressed(MouseEvent arg0) { + // 鼠标按键在组件上按下时 changed = true; } @Override public void mouseExited(MouseEvent arg0) { + // 鼠标离开组件时 } @Override public void mouseEntered(MouseEvent arg0) { + // 鼠标进入到组件时 } @Override public void mouseClicked(MouseEvent arg0) { + // 鼠标按键在组件上单击时 } }; } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java index 4efd505890..4a24c8de25 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java @@ -18,11 +18,11 @@ public class UICombinationButton extends JPanel{ protected UIButton rightButton; protected void leftButtonClickEvent() { - + // 左边按钮点击事件 } protected void rightButtonClickEvent() { - + // 右边按钮点击事件 } public UICombinationButton() { diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButtonUI.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButtonUI.java index 6a92f5057b..6b406588b6 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButtonUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButtonUI.java @@ -176,11 +176,11 @@ public class UISliderButtonUI extends BasicButtonUI { private void fillNormal(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited, boolean isPressedPainted) { GradientPaint gp; if (DesignerMode.isAuthorityEditing() && isAuthorityEdited) { - gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1f, UIConstants.AUTHORITY_DARK_BLUE); + gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1F, UIConstants.AUTHORITY_DARK_BLUE); } else if (isPressedPainted) { - gp = new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, height - 1, UIConstants.SELECT_TAB); + gp = new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, height - 1F, UIConstants.SELECT_TAB); }else{ - gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1, UIConstants.POP_DIALOG_BORDER); + gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1F, UIConstants.POP_DIALOG_BORDER); } fillPaint(g2d, x, y, width, height, isRound, rectDirection, gp, UIConstants.ARC); @@ -189,11 +189,11 @@ public class UISliderButtonUI extends BasicButtonUI { private void fillRollOver(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited, boolean isPressedPainted) { GradientPaint gp; if (DesignerMode.isAuthorityEditing() && isAuthorityEdited) { - gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1, UIConstants.HOVER_BLUE); + gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1F, UIConstants.HOVER_BLUE); } else if (isPressedPainted) { - gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1, UIConstants.POP_DIALOG_BORDER); + gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1F, UIConstants.POP_DIALOG_BORDER); }else { - gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1, UIConstants.POP_DIALOG_BORDER); + gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1F, UIConstants.POP_DIALOG_BORDER); } fillPaint(g2d, x, y, width, height, isRound, rectDirection, gp, UIConstants.ARC); } @@ -225,4 +225,4 @@ public class UISliderButtonUI extends BasicButtonUI { g2d.setColor(oldColor); } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UITabButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UITabButton.java index 4e50dd9942..ce609cde88 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UITabButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UITabButton.java @@ -162,12 +162,12 @@ public class UITabButton extends UILabel implements UISelectedComponent { Color blue = UIConstants.LIGHT_BLUE; g2d.setColor(blue); g2d.fillRect(0, 1, w - 1, h / 2); - GradientPaint gp = new GradientPaint(1, 1, UIConstants.OCEAN_BLUE, 1, h - 1, blue); + GradientPaint gp = new GradientPaint(1, 1, UIConstants.OCEAN_BLUE, 1, h - 1F, blue); g2d.setPaint(gp); g2d.fillRect(0, h / 2, w - 1, h / 2); this.setForeground(UIConstants.FONT_COLOR); } else if (!isSelected() && !isRollover) { - GradientPaint gp = new GradientPaint(1, 1, TOP, 1, h - 1, DOWN); + GradientPaint gp = new GradientPaint(1, 1, TOP, 1, h - 1F, DOWN); g2d.setPaint(gp); g2d.fillRect(0, h / 2, w - 1, h / 2); this.setForeground(UIConstants.FONT_COLOR); @@ -178,4 +178,4 @@ public class UITabButton extends UILabel implements UISelectedComponent { } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java index 45c878419e..2ba4f02439 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java @@ -220,7 +220,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ protected void paintOtherBorder(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setStroke(UIConstants.BS); - Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); + Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1F, getHeight() - 1F, UIConstants.ARC, UIConstants.ARC); g2d.setColor(UIConstants.LINE_COLOR); g2d.draw(shape); } @@ -252,4 +252,4 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ return true; } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java index 74cd42a7ef..ca4eddfe3e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java @@ -3,6 +3,11 @@ */ package com.fr.design.gui.icombobox; +import com.fr.base.FRContext; +import com.fr.base.GraphHelper; +import com.fr.base.ScreenResolution; +import com.fr.general.FRFont; +import com.fr.stable.Constants; import java.awt.Component; import java.awt.Dimension; import java.awt.Font; @@ -11,18 +16,10 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.GeneralPath; import java.awt.geom.Point2D; - import javax.swing.DefaultComboBoxModel; import javax.swing.JLabel; import javax.swing.JList; -import com.fr.base.FRContext; -import com.fr.base.GraphHelper; -import com.fr.base.ScreenResolution; -import com.fr.general.FRFont; - -import com.fr.stable.Constants; - /** * Combobox for selecting line styles. @@ -88,13 +85,13 @@ public class LineComboBox extends UIComboBox { FontMetrics fm = GraphHelper.getFontMetrics(rfont); if (style == Constants.LINE_NONE) { //draw "none" string - GraphHelper.drawString(g2d, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None"), 4, (d.height - fm.getHeight()) / 2 + fm.getAscent()); + GraphHelper.drawString(g2d, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None"), 4, (d.height - fm.getHeight()) / 2D + fm.getAscent()); } else { - GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2, style); + GraphHelper.drawLine(g2d, 4, d.height / 2D, d.width - 8D, d.height / 2D, style); } if(isShowAxisWithLineStyle()) { // 带有坐标轴箭头的样式. - drawArrow(g2d, new Point2D.Double(4, d.height / 2), new Point2D.Double(d.width - 8, d.height/2)); + drawArrow(g2d, new Point2D.Double(4, d.height / 2D), new Point2D.Double(d.width - 8D, d.height / 2D)); } } @@ -142,4 +139,4 @@ public class LineComboBox extends UIComboBox { private int style = Constants.LINE_NONE; } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxButton.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxButton.java index 9f96f655eb..6130050dc2 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxButton.java @@ -172,11 +172,9 @@ public class UIComboBoxButton extends JButton { } c.setBackground(UIManager.getColor("ComboBox.focusBackground")); if (c instanceof JComponent) { - mustResetOpaque = true; JComponent jc = (JComponent) c; - savedOpaque = jc.isOpaque(); + jc.isOpaque(); jc.setOpaque(true); - paintFocus = true; } } else { c.setForeground(comboBox.getForeground()); diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIModeControlContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIModeControlContainer.java index eadb94109f..4d844336f1 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIModeControlContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIModeControlContainer.java @@ -46,7 +46,7 @@ public class UIModeControlContainer extends JLayeredPane { private boolean isHideMode = false; private boolean isSheeetCovered = false; - private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 30 / 100.0F); + private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f); public UIModeControlContainer() { this(new JPanel(), new JPanel()); diff --git a/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java b/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java index 432628f0fa..ebccd24f45 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java @@ -1,5 +1,6 @@ package com.fr.design.gui.ilable; +import javax.swing.event.MouseInputAdapter; import java.awt.Color; import java.awt.Cursor; import java.awt.Graphics; @@ -7,9 +8,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; -import com.fr.design.gui.ilable.UILabel; -import javax.swing.event.MouseInputAdapter; - /** * Action label */ @@ -31,6 +29,7 @@ public class ActionLabel extends UILabel { /** * Repaints the text. */ + @Override public void paintComponent(Graphics _gfx) { super.paintComponent(_gfx); @@ -39,12 +38,17 @@ public class ActionLabel extends UILabel { } private MouseInputAdapter mouseInputAdapter = new MouseInputAdapter() { + @Override public void mouseClicked(MouseEvent e) { + //do nothing } + @Override public void mousePressed(MouseEvent e) { + //do nothing } + @Override public void mouseReleased(MouseEvent evt) { Object source = evt.getSource(); @@ -65,6 +69,7 @@ public class ActionLabel extends UILabel { } } + @Override public void mouseExited(MouseEvent evt) { Object source = evt.getSource(); @@ -73,6 +78,7 @@ public class ActionLabel extends UILabel { } } + @Override public void mouseDragged(MouseEvent e) { } diff --git a/designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java index 844120c51b..a14de81c55 100644 --- a/designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java @@ -287,7 +287,7 @@ public class UIBasicMenuItemUI extends MenuItemUI { View v = (View) c.getClientProperty(BasicHTML.propertyKey); if (v != null) { d = getPreferredSize(c); - d.width -= v.getPreferredSpan(View.X_AXIS) - v.getMinimumSpan(View.X_AXIS); + d.width -= (double) v.getPreferredSpan(View.X_AXIS) - (double) v.getMinimumSpan(View.X_AXIS); } return d; } @@ -345,7 +345,7 @@ public class UIBasicMenuItemUI extends MenuItemUI { View v = (View) c.getClientProperty(BasicHTML.propertyKey); if (v != null) { d = getPreferredSize(c); - d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS); + d.width += (double) v.getMaximumSpan(View.X_AXIS) - (double) v.getPreferredSpan(View.X_AXIS); } return d; } @@ -816,7 +816,6 @@ public class UIBasicMenuItemUI extends MenuItemUI { // get Accelerator text KeyStroke accelerator = b.getAccelerator(); String acceleratorText = ""; - drawMenu(acceleratorText, accelerator, c, ic, maxValue, offset, paintIcon, b); String text = layoutMenuItem(fm, b.getText(), fmAccel, acceleratorText, ic, null, arrowIcon, b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, @@ -834,43 +833,6 @@ public class UIBasicMenuItemUI extends MenuItemUI { g.setFont(holdf); } - private void drawMenu(String acceleratorText, KeyStroke accelerator, JComponent c, - Icon ic, int maxValue, int offset, Icon paintIcon, JMenuItem b) { - if (accelerator != null) { - int modifiers = accelerator.getModifiers(); - if (modifiers > 0) { - acceleratorText = KeyEvent.getKeyModifiersText(modifiers); - //acceleratorText += "-"; - acceleratorText += acceleratorDelimiter; - } - - int keyCode = accelerator.getKeyCode(); - if (keyCode != 0) { - acceleratorText += KeyEvent.getKeyText(keyCode); - } else { - acceleratorText += accelerator.getKeyChar(); - } - } - if (!isTopLevelMenu()) { - if (c instanceof JCheckBoxMenuItem || c instanceof JRadioButtonMenuItem) { - ic = checkIcon; - if (checkIcon.getIconWidth() < maxValue) { - ic = new EmptyIcon(maxValue, checkIcon.getIconHeight()); - offset = (maxValue - checkIcon.getIconWidth()) / 2; - } - paintIcon = null; - } else if (c instanceof JMenuItem) { - if (ic == null || ic.getIconWidth() < maxValue) { - int height = (ic == null) ? 2 : b.getIcon().getIconHeight(); - int width = (ic == null) ? 2 : b.getIcon().getIconWidth(); - offset = (maxValue - width) / 2; - ic = new EmptyIcon(maxValue, height); - } - } - } - } - - private void drawAccText(String acceleratorText, Graphics g, JComponent p, ButtonModel model, FontMetrics fmAccel, JComponent c) { if (acceleratorText != null && !ComparatorUtils.equals(acceleratorText, "")) { //Get the maxAccWidth from the parent to calculate the offset. diff --git a/designer-base/src/main/java/com/fr/design/gui/imenutable/UIMenuTable.java b/designer-base/src/main/java/com/fr/design/gui/imenutable/UIMenuTable.java index d950e91ed7..938e0caccc 100644 --- a/designer-base/src/main/java/com/fr/design/gui/imenutable/UIMenuTable.java +++ b/designer-base/src/main/java/com/fr/design/gui/imenutable/UIMenuTable.java @@ -157,8 +157,7 @@ public class UIMenuTable extends JTable { @Override public TableCellRenderer getDefaultRenderer(Class columnClass) { - columnClass = UITable.class; - return super.getDefaultRenderer(columnClass); + return super.getDefaultRenderer(UITable.class); } private class UITableRender implements TableCellRenderer { diff --git a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java index a9b470a58d..e416083f73 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java +++ b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java @@ -3,6 +3,9 @@ package com.fr.design.gui.iprogressbar; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.ilable.UILabel; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; @@ -28,7 +31,12 @@ public class ProgressDialog extends UIDialog { setUndecorated(true); setSize(parent.getSize()); setLocationRelativeTo(null); - setOpacity(0.5f); + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + setOpacity(0.5f); + } + }, SupportOSImpl.OPACITY); initComponent(); } diff --git a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/UIProgressBorder.java b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/UIProgressBorder.java index c4df50e82a..30074f5638 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/UIProgressBorder.java +++ b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/UIProgressBorder.java @@ -72,6 +72,7 @@ public class UIProgressBorder extends UIRoundedBorder { g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } + @SuppressWarnings("squid:S2164") private void paintBorderShadow(Graphics2D g2, int shadowWidth, int x, int y, int width, int height) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); shadowWidth = Math.max(shadowWidth, 2); @@ -85,6 +86,7 @@ public class UIProgressBorder extends UIRoundedBorder { } } + @SuppressWarnings("squid:S2164") private static Color getMixedColor(Color c1, float pct1, Color c2, float pct2) { float[] clr1 = c1.getComponents(null); float[] clr2 = c2.getComponents(null); diff --git a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIBasicScrollBarUI.java b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIBasicScrollBarUI.java index 851f907977..821ebbc335 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIBasicScrollBarUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIBasicScrollBarUI.java @@ -165,50 +165,6 @@ public class UIBasicScrollBarUI extends BasicScrollBarUI { // drawColorAndLength(g, t, x2, y2, color); } - private void drawColorAndLength(Graphics g, Rectangle t, int x2, int y2, Color color) { - - if (scrollbar.getOrientation() == JScrollBar.VERTICAL) { - int y1 = t.y + (t.height) / 2 - 4; - y2 = Math.min(y1 + 8, t.y + t.height - 5); - - int y = y1; - // we take only saturation & brightness and apply them - // to the background color (normal/rollover/pressed) - g.setColor(UISBChooser.getAdjustedColor(color, 0, 71)); - while (y < y2) { - g.drawLine(5, y, 11, y); - y += 2; - } - - y = y1 + 1; - g.setColor(UISBChooser.getAdjustedColor(color, 0, -13)); - while (y < y2) { - g.drawLine(6, y, 12, y); - y += 2; - } - } else { - int x1 = t.x + (t.width) / 2 - 4; - x2 = Math.min(x1 + 8, t.x + t.width - 5); - - int x = x1 + 1; - // we take only saturation & brightness and apply them - // to the background color (normal/rollover/pressed) - g.setColor(UISBChooser.getAdjustedColor(color, 0, 71)); - while (x < x2) { - g.drawLine(x, 5, x, 11); - x += 2; - } - - x = x1; - g.setColor(UISBChooser.getAdjustedColor(color, 0, -13)); - while (x < x2) { - g.drawLine(x, 6, x, 12); - x += 2; - } - } - } - - private void drawVertical(Graphics g, Rectangle t, int xs, int ys, int x2, Color pressedColor, Color rolloverColor, Color normalColor) { diff --git a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UISBChooser.java b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UISBChooser.java index a6ba742830..c780eeb2d7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UISBChooser.java +++ b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UISBChooser.java @@ -90,6 +90,7 @@ public class UISBChooser extends JDialog { (frame.getHeight() - getSize().height) / 2); } + @SuppressWarnings("squid:S1226") private void initP3(JPanel p3, JPanel p1) { p3 = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 8)); p3.add(new JLabel("R:")); @@ -198,6 +199,7 @@ public class UISBChooser extends JDialog { twoColorField.setUpperColor(outColor); } + @SuppressWarnings("squid:S2164") public static Color getAdjustedColor(Color inColor, int sat, int bri) { Color briColor = inColor; @@ -219,9 +221,9 @@ public class UISBChooser extends JDialog { int dg = briColor.getGreen() - satColor.getGreen(); int db = briColor.getBlue() - satColor.getBlue(); - r = briColor.getRed() - (int) Math.round(dr * sat / VALUE * 1.0); - g = briColor.getGreen() - (int) Math.round(dg * sat / VALUE * 1.0); - b = briColor.getBlue() - (int) Math.round(db * sat / VALUE * 1.0); + r = briColor.getRed() - (int) Math.round(dr * sat / (VALUE * 1.0)); + g = briColor.getGreen() - (int) Math.round(dg * sat / (VALUE * 1.0)); + b = briColor.getBlue() - (int) Math.round(db * sat / (VALUE * 1.0)); } else { float d = ColorRoutines.getGreyValue(briColor); float dr = briColor.getRed() - d; diff --git a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java index d3393054ae..949b3958ae 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java @@ -2,6 +2,25 @@ package com.fr.design.gui.iscrollbar; import com.fr.design.constants.UIConstants; import com.fr.stable.StringUtils; +import sun.swing.DefaultLookup; + +import javax.swing.BoundedRangeModel; +import javax.swing.InputMap; +import javax.swing.JComponent; +import javax.swing.JList; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; +import javax.swing.JViewport; +import javax.swing.LookAndFeel; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; +import javax.swing.Timer; +import javax.swing.UIManager; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.ScrollBarUI; +import javax.swing.plaf.UIResource; import java.awt.Color; import java.awt.Component; import java.awt.Container; @@ -22,24 +41,6 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import javax.swing.BoundedRangeModel; -import javax.swing.InputMap; -import javax.swing.JComponent; -import javax.swing.JList; -import javax.swing.JScrollBar; -import javax.swing.JScrollPane; -import javax.swing.JViewport; -import javax.swing.LookAndFeel; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.Timer; -import javax.swing.UIManager; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.ScrollBarUI; -import javax.swing.plaf.UIResource; -import sun.swing.DefaultLookup; /** * Like BasicScrollBarUI,but without two buttons @@ -590,6 +591,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo * will cause a repaint. */ + @SuppressWarnings("squid:S2164") protected void layoutVScrollbar(JScrollBar sb) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); @@ -672,6 +674,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo * Make sure the thumb fits between the buttons. Note that setting the * thumbs bounds causes a repaint. */ + @SuppressWarnings("squid:S2164") protected void layoutHScrollbar(JScrollBar sb) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); @@ -1080,7 +1083,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo scrollbar.repaint(); } - + @SuppressWarnings("squid:S2164") private void setValueFrom(MouseEvent e) { boolean active = isThumbRollover(); BoundedRangeModel model = scrollbar.getModel(); diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java index 66a9a75755..fb6752ac19 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java @@ -39,6 +39,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver private String spinnerName = StringUtils.EMPTY; private UIObserverListener uiObserverListener; private GlobalNameListener globalNameListener = null; + private boolean lessMinValue = false; public UISpinner(double minValue, double maxValue, double dierta) { @@ -93,6 +94,18 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver return textField; } + public UIButton getNextButton() { + return nextButton; + } + + public boolean isLessMinValue() { + return lessMinValue; + } + + public void resetLessMinValue() { + lessMinValue = false; + } + public void setValue(double value) { setValue(value, true); } @@ -109,7 +122,8 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver if (globalNameListener != null && shouldResponseNameListener()) { globalNameListener.setGlobalName(spinnerName); } - value = value < minValue ? minValue : value; + lessMinValue = value < minValue; + value = lessMinValue ? minValue : value; value = value > maxValue ? maxValue : value; if (CommonUtils.equals(value, this.value)) { return; @@ -131,7 +145,8 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver if (globalNameListener != null && shouldResponseNameListener()) { globalNameListener.setGlobalName(spinnerName); } - value = value < minValue ? minValue : value; + lessMinValue = value < minValue; + value = lessMinValue ? minValue : value; value = value > maxValue ? maxValue : value; if (CommonUtils.equals(value, this.value)) { diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java index 1515477a3d..42a40cd79e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java @@ -3,8 +3,6 @@ package com.fr.design.gui.ispinner; import com.fr.design.gui.itextfield.UIIntNumberField; import com.fr.design.gui.itextfield.UINumberField; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; /** * Created by IntelliJ IDEA. @@ -31,7 +29,7 @@ public class UnsignedIntUISpinner extends UISpinner { @Override protected UINumberField initNumberField() { - final UIIntNumberField numberField = new UIIntNumberField() { + return new UIIntNumberField() { public boolean shouldResponseChangeListener() { return false; } @@ -44,29 +42,5 @@ public class UnsignedIntUISpinner extends UISpinner { }; } }; - numberField.addFocusListener(new FocusListener() { - @Override - public void focusGained(FocusEvent e) { - - } - - /** - * 失去焦点后再做范围限制、不然最小值为 100 时,输个 1 都不让.... - * @param e - */ - @Override - public void focusLost(FocusEvent e) { - double value = numberField.getValue(); - if (!isOverMaxOrMinValue(value)) { - return; - } - numberField.setValue(value < minValue ? minValue : maxValue); - } - - private boolean isOverMaxOrMinValue(double value) { - return value < minValue || value > maxValue; - } - }); - return numberField; } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/itable/UITable.java b/designer-base/src/main/java/com/fr/design/gui/itable/UITable.java index ca214c4241..e5dcd7fd14 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itable/UITable.java +++ b/designer-base/src/main/java/com/fr/design/gui/itable/UITable.java @@ -291,8 +291,7 @@ public class UITable extends JTable implements UIObserver { * */ public TableCellEditor getDefaultEditor(Class columnClass) { - columnClass = UITable.class; - return super.getDefaultEditor(columnClass); + return super.getDefaultEditor(UITable.class); } @Override @@ -300,8 +299,7 @@ public class UITable extends JTable implements UIObserver { * */ public TableCellRenderer getDefaultRenderer(Class columnClass) { - columnClass = UITable.class; - return super.getDefaultRenderer(columnClass); + return super.getDefaultRenderer(UITable.class); } /** 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/gui/style/AlignmentPane.java b/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java index 9bbca6d2bc..b188cb5aa8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java @@ -102,7 +102,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal_white.png")}, {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment_white.png")}}; Integer[] hAlignment = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT, Integer.valueOf(Constants.DISTRIBUTED), Constants.NULL}; - hAlignmentPane = new UIButtonGroup(hAlignmentIconArray, hAlignment); + hAlignmentPane = new UIButtonGroup<>(hAlignmentIconArray, hAlignment); hAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Left"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Right"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Distributed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_DEFAULT")}); hPaneContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); @@ -112,7 +112,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal_white.png")}, {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal_white.png")}}; Integer[] vAlignment = new Integer[]{Constants.TOP, Constants.CENTER, Constants.BOTTOM}; - vAlignmentPane = new UIButtonGroup(vAlignmentIconArray, vAlignment); + vAlignmentPane = new UIButtonGroup<>(vAlignmentIconArray, vAlignment); vAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Top"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Bottom")}); initOtherComponent(); initAllNames(); @@ -174,7 +174,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO } private void initTextRotationCombox() { - ArrayList selectOption = new ArrayList(); + ArrayList selectOption = new ArrayList<>(); selectOption.add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Angle")); VerticalTextProcessor processor = ExtraClassManager.getInstance().getSingle(VerticalTextProcessor.XML_TAG, DefaultVerticalTextProcessor.class); selectOption.addAll(Arrays.asList(processor.getComboxOption())); @@ -343,8 +343,8 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO int rightPadding = indentationUnitProcessor.paddingUnitProcessor(style.getPaddingRight()); // alex:indent - this.leftIndentSpinner.setValue(new Integer(leftPadding)); - this.rightIndentSpinner.setValue(new Integer(rightPadding)); + this.leftIndentSpinner.setValue(leftPadding); + this.rightIndentSpinner.setValue(rightPadding); this.spaceBeforeSpinner.setValue(style.getSpacingBefore()); this.spaceAfterSpinner.setValue(style.getSpacingAfter()); @@ -360,7 +360,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO public Style update(Style style) { // peter:需要判断传递进来的值是否为null. if (style == null) { - return style; + return null; } if (ComparatorUtils.equals(globalNameListener.getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Pane_Horizontal"))) { @@ -463,7 +463,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO } /** - * @param name + * @param name 全局名 */ public void setGlobalName(String name) { } diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java b/designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java index ee397d7559..dc706416c6 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java @@ -1,10 +1,14 @@ package com.fr.design.gui.style; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.itextfield.UITextField; +import com.fr.module.ModuleContext; +import com.fr.value.ClearableLazyValue; +import org.jetbrains.annotations.NotNull; -import java.util.Timer; -import java.util.TimerTask; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; /** * Created with IntelliJ IDEA. @@ -14,31 +18,35 @@ import java.util.TimerTask; * To change this template use File | Settings | File Templates. */ public class FormatePaneNumField extends UITextField { - private Timer timer; + private ClearableLazyValue ses = new ClearableLazyValue() { + @NotNull + @Override + protected ScheduledExecutorService compute() { + return ModuleContext.getExecutor() + .newSingleThreadScheduledExecutor(new NamedThreadFactory("FormatePaneNumFieldRunChange")); + } + }; + public FormatePaneNumField() { super(); } + @Override protected void attributeChange() { if (!AbstractAttrNoScrollPane.isHasChangeListener()) { return; } - if(timer != null){ - timer.cancel(); - } - timer = new Timer(); - timer.schedule(new TimerTask() { + ses.getValue().schedule(new Runnable() { @Override public void run() { runChange(); } - },100); - + }, 100, TimeUnit.MILLISECONDS); } - protected void runChange(){ + protected void runChange() { super.attributeChange(); - timer.cancel(); - + ses.getValue().shutdown(); + ses.drop(); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/print/RPrintUtilities.java b/designer-base/src/main/java/com/fr/design/gui/syntax/print/RPrintUtilities.java index 352676010c..749bf45408 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/print/RPrintUtilities.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/print/RPrintUtilities.java @@ -9,6 +9,8 @@ */ package com.fr.design.gui.syntax.print; +import com.fr.log.FineLoggerFactory; + import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.Element; @@ -62,8 +64,8 @@ public abstract class RPrintUtilities { private static int getLineBreakPoint(String line, final int maxCharsPerLine) { int breakPoint = -1; - for (int i=0; i breakPoint) breakPoint = breakCharPos; } @@ -147,11 +149,11 @@ public abstract class RPrintUtilities { int tabIndex = curLineString.indexOf('\t'); while (tabIndex > -1) { int spacesNeeded = tabSizeInSpaces - (tabIndex % tabSizeInSpaces); - String replacementString = ""; + StringBuilder replacementString = new StringBuilder(); for (int i=0; i-1 && pos>currentPos) // currentPos = pos; - if (pos>0 && pos>currentPos & pos!=currentLineString.length()) + if (pos > 0 && pos > currentPos & pos != currentLineString.length()) currentPos = pos; } @@ -440,7 +442,7 @@ public abstract class RPrintUtilities { try { doc.getText(currentLineStart+startingOffset, currentPos, currentLineSeg); } catch (BadLocationException ble) { - System.err.println(ble); + FineLoggerFactory.getLogger().error(ble.getMessage()); return Printable.NO_SUCH_PAGE; } currentLineLengthInPixels = Utilities. @@ -453,12 +455,11 @@ public abstract class RPrintUtilities { try { doc.getText((currentLineStart+startingOffset), currentPos, currentLineSeg); } catch (BadLocationException ble) { - System.err.println("BadLocationException in print (a):"); - System.err.println("==> currentLineStart: " + currentLineStart + - "; startingOffset: " + startingOffset + "; currentPos: " + currentPos); - System.err.println("==> Range: " + (currentLineStart+startingOffset) + " - " + - (currentLineStart+startingOffset+currentPos)); - ble.printStackTrace(); + FineLoggerFactory.getLogger().error("BadLocationException in print (a):" + "==> currentLineStart: " + currentLineStart + + "; startingOffset: " + startingOffset + "; currentPos: " + currentPos + + "==> Range: " + (currentLineStart+startingOffset) + " - " + + (currentLineStart+startingOffset+currentPos)); + FineLoggerFactory.getLogger().error(ble.getMessage()); return Printable.NO_SUCH_PAGE; } @@ -521,7 +522,8 @@ public abstract class RPrintUtilities { return x; int tabSizeInPixels = tabSizeInSpaces * fm.charWidth(' '); int ntabs = (((int) x) - xOffset) / tabSizeInPixels; - return xOffset + ((ntabs + 1) * tabSizeInPixels); + double reFloat = (double) xOffset + (double) ((ntabs + 1) * tabSizeInPixels); + return (float) reFloat; } } diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java index ddb3ddfa3c..596c5d9bd9 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java @@ -518,6 +518,8 @@ public class RSyntaxUtilities implements SwingConstants { } numEmbedded--; } + } else { + //do nothing } } // End of for (int i=segOffset; i { token = null; } } + else { + throw new NoSuchElementException(); + } return t; } diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java index e99208afc0..97e367ef0c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java @@ -268,7 +268,7 @@ public class WrappedSyntaxView extends BoxView implements TabExpander, if (host.getEOLMarkersVisible()) { g.setColor(host.getForegroundForTokenType(Token.WHITESPACE)); g.setFont(host.getFontForTokenType(Token.WHITESPACE)); - g.drawString("\u00B6", x, y-fontHeight); + g.drawString("\u00B6", x, (float) (y-fontHeight)); } } @@ -458,7 +458,7 @@ public class WrappedSyntaxView extends BoxView implements TabExpander, if (host.getEOLMarkersVisible()) { g.setColor(host.getForegroundForTokenType(Token.WHITESPACE)); g.setFont(host.getFontForTokenType(Token.WHITESPACE)); - g.drawString("\u00B6", x, y-fontHeight); + g.drawString("\u00B6", x, (float) (y-fontHeight)); } } @@ -841,10 +841,11 @@ public class WrappedSyntaxView extends BoxView implements TabExpander, * @return the tab stop, measured in points >= 0 */ public float nextTabStop(float x, int tabOffset) { - if (tabSize == 0) + if (tabSize == 0) { return x; + } int ntabs = ((int) x - tabBase) / tabSize; - return tabBase + ((ntabs + 1) * tabSize); + return (float) (tabBase + ((ntabs + 1) * tabSize)); } diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/folding/HtmlFoldParser.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/folding/HtmlFoldParser.java index 79d8da0a30..41f51215c7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/folding/HtmlFoldParser.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/folding/HtmlFoldParser.java @@ -172,7 +172,7 @@ public class HtmlFoldParser implements FoldParser { // Continuing an MLC from a previous line if (inMLC) { // Found the end of the MLC starting on a previous line... - if (t.endsWith(MLC_END)) { + if (currentFold != null && t.endsWith(MLC_END)) { int mlcEnd = t.getEndOffset() - 1; currentFold.setEndOffset(mlcEnd); Fold parentFold = currentFold.getParent(); diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/FormulaTokenMaker.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/FormulaTokenMaker.java index aae7216734..98b5265c39 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/FormulaTokenMaker.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/FormulaTokenMaker.java @@ -18,6 +18,7 @@ import java.io.IOException; * on 9/18/19 6:12 PM from the specification file * /Users/3dot141/Downloads/FolxDownload/App/jflex-1.4.1/bin/FormulaTokenMaker.flex */ +@SuppressWarnings("squid:S1192") public class FormulaTokenMaker extends AbstractJFlexCTokenMaker { /** This character denotes the end of file */ diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaEditorKit.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaEditorKit.java index 277064c2f9..de97867fbb 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaEditorKit.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaEditorKit.java @@ -741,10 +741,10 @@ public class RTextAreaEditorKit extends DefaultEditorKit { public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { Font font = textArea.getFont(); float oldSize = font.getSize2D(); - float newSize = oldSize - decreaseAmount; + double newSize = (double)oldSize - (double)decreaseAmount; if (newSize>=MINIMUM_SIZE) { // Shrink by decreaseAmount. - font = font.deriveFont(newSize); + font = font.deriveFont((float)newSize); textArea.setFont(font); } else if (oldSize>MINIMUM_SIZE) { @@ -1329,10 +1329,10 @@ public class RTextAreaEditorKit extends DefaultEditorKit { public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { Font font = textArea.getFont(); float oldSize = font.getSize2D(); - float newSize = oldSize + increaseAmount; + double newSize = (double)oldSize + (double)increaseAmount; if (newSize<=MAXIMUM_SIZE) { // Grow by increaseAmount. - font = font.deriveFont(newSize); + font = font.deriveFont((float)newSize); textArea.setFont(font); } else if (oldSize { @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/layout/FRGUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java index 90a5bc9586..0c3a067a95 100644 --- a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java @@ -558,15 +558,15 @@ public class FRGUIPaneFactory { */ public static int caculateWidth(int width) { int w = 0; - float m = (width + WIDTH_OFFSET_M) / WIDTH_PARA_F; - float n = (width + WIDTH_OFFSET_N) / WIDTH_PARA_F; - float i = Math.abs((((int) m + (int) (m + 1)) / WIDTHABS_PARA_F) - m); - float j = Math.abs((((int) n + (int) (n + 1)) / WIDTHABS_PARA_F) - n); - float x = i > j ? i : j; + double m = (double)(width + WIDTH_OFFSET_M) / (double)WIDTH_PARA_F; + double n = (double)(width + WIDTH_OFFSET_N ) / (double)WIDTH_PARA_F; + double i = Math.abs(((double) ((int) m + (int) (m + 1)) / WIDTHABS_PARA_F) - m); + double j = Math.abs(((double) ((int) n + (int) (n + 1)) / WIDTHABS_PARA_F) - n); + double x = i > j ? i : j; if (AssistUtils.equals(x, i)) { - w = Math.round(m) * WIDTH_PARA_INT - WIDTH_OFFSET_M; + w = (int) (Math.round(m) * WIDTH_PARA_INT - WIDTH_OFFSET_M); } else if (AssistUtils.equals(x, j)) { - w = Math.round(n) * WIDTH_PARA_INT - WIDTH_OFFSET_N; + w = (int) (Math.round(n) * WIDTH_PARA_INT - WIDTH_OFFSET_N); } return w; } @@ -579,7 +579,7 @@ public class FRGUIPaneFactory { */ public static int caculateHeight(int height) { int h = 0; - float x = (height + HEIGHT_OFFSET) / HEIGHT_PARA; + double x = (double)(height + HEIGHT_OFFSET) / HEIGHT_PARA; h = ((int) x + 1) * HEIGHT_PARA; return h; } diff --git a/designer-base/src/main/java/com/fr/design/layout/TableLayout.java b/designer-base/src/main/java/com/fr/design/layout/TableLayout.java index f8134be1fd..2cf288da63 100644 --- a/designer-base/src/main/java/com/fr/design/layout/TableLayout.java +++ b/designer-base/src/main/java/com/fr/design/layout/TableLayout.java @@ -1747,7 +1747,7 @@ public class TableLayout implements LayoutManager2, Serializable { for (counter = 0; counter < numCr; counter++) if ((crSpec[z][counter] > 0.0) && (crSpec[z][counter] < 1.0)) fillSizeRatio -= crSpec[z][counter]; - else if (crSpec[z][counter] == FILL) + else if (AssistUtils.equals(crSpec[z][counter], FILL)) numFillSize++; // Adjust fill ratios to reflect number of fill rows/columns @@ -1773,8 +1773,8 @@ public class TableLayout implements LayoutManager2, Serializable { int crPrefMin[] = new int[numCr]; for (counter = 0; counter < numCr; counter++) - if ((crSpec[z][counter] == PREFERRED) || - (crSpec[z][counter] == MINIMUM)) { + if ((AssistUtils.equals(crSpec[z][counter], PREFERRED)) || + (AssistUtils.equals(crSpec[z][counter], MINIMUM))) { crPrefMin[counter] = crSize[z][counter]; } diff --git a/designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java b/designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java index b26e057ef5..1be77c8492 100644 --- a/designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java +++ b/designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java @@ -372,7 +372,7 @@ public class TableLayoutHelper { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; JPanel jp1 = TableLayoutHelper.createTableLayoutPane(createTestComponents("jp1"), TableLayoutHelper.FILL_NONE); - JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(createTestComponents("jp2"), TableLayoutHelper.FILL_LASTCOL_AND_ROW, 2 * TEN, 2 * TEN); + JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(createTestComponents("jp2"), TableLayoutHelper.FILL_LASTCOL_AND_ROW, (double)2 * TEN, (double)2 * TEN); JPanel jp3 = TableLayoutHelper.createGapTableLayoutPane(createTestComponents("jp3"), new double[]{f, p, f, p}, new double[]{f, f}, 4, 4); JPanel jp4 = TableLayoutHelper.createGapTableLayoutPane(createTestComponents("jp4"), 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 b422be44e8..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; @@ -40,6 +39,7 @@ import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.menu.MenuManager; import com.fr.design.menu.ShortCut; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.event.EventDispatcher; import com.fr.exception.DecryptTemplateException; @@ -58,6 +58,8 @@ import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.image4j.codec.ico.ICODecoder; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; import com.fr.stable.project.ProjectConstants; import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; @@ -83,6 +85,7 @@ import java.awt.Graphics; import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; +import java.awt.Component; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.dnd.DnDConstants; @@ -109,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; @@ -141,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(); @@ -180,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(); @@ -314,7 +317,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public void componentResized(ComponentEvent e) { reCalculateFrameSize(); - if (DesignerMode.isAuthorityEditing()) { + if (DesignModeContext.isAuthorityEditing()) { doResize(); } } @@ -330,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() { @@ -412,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的时候修改右上的组件构成 @@ -449,20 +452,33 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta return northEastPane; } - private void refreshNorthEastPane(JPanel northEastPane, ToolBarMenuDock ad) { + private void refreshNorthEastPane(final JPanel northEastPane, final ToolBarMenuDock ad) { northEastPane.removeAll(); northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); northEastPane.add(LogMessageBar.getInstance()); TitlePlaceProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TitlePlaceProcessor.MARK_STRING); if (processor != null) { - processor.hold(northEastPane, LogMessageBar.getInstance(), ad.createBBSLoginPane()); + final Component[] bbsLoginPane = {null}; + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + bbsLoginPane[0] = ad.createBBSLoginPane(); + } + }, SupportOSImpl.USERINFOPANE); + processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]); } northEastPane.add(ad.createAlphaFinePane()); if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { ad.createAlphaFinePane().setVisible(false); } - northEastPane.add(ad.createBBSLoginPane()); + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + northEastPane.add(ad.createBBSLoginPane()); + } + }, SupportOSImpl.USERINFOPANE); + } public void initTitleIcon() { @@ -498,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; } @@ -576,7 +592,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ public void refreshDottedLine() { - if (DesignerMode.isAuthorityEditing()) { + if (DesignModeContext.isAuthorityEditing()) { populateAuthorityArea(); populateCloseButton(); addDottedLine(); @@ -616,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()) { @@ -659,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) { @@ -675,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; } @@ -692,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; } @@ -767,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()); } } } @@ -794,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(" "); @@ -892,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; } @@ -1075,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); } @@ -1089,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 { @@ -1098,11 +1114,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } } - /** - * Exit退出 - */ - public void exit() { - + public void prepareForExit() { Thread thread = new Thread() { @Override @@ -1121,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()); @@ -1133,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(); @@ -1234,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 ff831160b6..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,7 +1,9 @@ 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; @@ -242,6 +244,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt /** * 响应数据集改变 */ + @Override public void fireDSChanged() { fireDSChanged(new HashMap()); @@ -252,6 +255,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt * * @param map 改变名字的数据集 */ + @Override public void fireDSChanged(Map map) { DesignTableDataManager.fireDSChanged(map); @@ -307,7 +311,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt return selectedOperation; } - /* + /** * 新建文件夹 */ private class NewFolderAction extends UpdateAction { @@ -363,17 +367,20 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt * 版本管理可用状态的监控 */ private void fireVcsActionChange() { - if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.getInstance().isUnSelectedTemplate() || FineClusterConfig.getInstance().isCluster()) { + if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() + || VcsHelper.getInstance().isUnSelectedTemplate() + || 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 { @@ -384,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)) { @@ -549,14 +563,17 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt nameField = new UITextField(oldName); nameField.getDocument().addDocumentListener(new DocumentListener() { + @Override public void changedUpdate(DocumentEvent e) { validInput(); } + @Override public void insertUpdate(DocumentEvent e) { validInput(); } + @Override public void removeUpdate(DocumentEvent e) { validInput(); } @@ -597,6 +614,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Confirm")); confirmButton.setPreferredSize(new Dimension(60, 25)); confirmButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { confirmClose(); } @@ -608,6 +626,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt cancelButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { dispose(); } @@ -764,14 +783,17 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt nameField = new UITextField(); nameField.getDocument().addDocumentListener(new DocumentListener() { + @Override public void changedUpdate(DocumentEvent e) { validInput(); } + @Override public void insertUpdate(DocumentEvent e) { validInput(); } + @Override public void removeUpdate(DocumentEvent e) { validInput(); } @@ -812,6 +834,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Confirm")); confirmButton.setPreferredSize(new Dimension(60, 25)); confirmButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { confirmClose(); } @@ -824,6 +847,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt cancelButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { dispose(); } 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/backgroundpane/PatternBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java index 5e69d9f829..9da1344dcd 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java @@ -164,11 +164,11 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane { Graphics2D g2d = (Graphics2D) g; Dimension d = getSize(); - this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); + this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, (double)d.width - 1, (double)d.height - 1)); if (this.pIndex == patternIndex) {// it's selected. g2d.setPaint(UIConstants.LINE_COLOR); - GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); + GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, (double)d.width - 1, (double)d.height - 1)); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java index 773498502a..0d94bf3bce 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java @@ -101,7 +101,7 @@ public class TextureBackgroundQuickPane extends BackgroundQuickPane { Dimension d = getSize(); g2d.setPaint(this.buttonTexturePaint); - GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); + GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, (double) d.width - 1, (double)d.height - 1)); if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's // selected. @@ -109,7 +109,7 @@ public class TextureBackgroundQuickPane extends BackgroundQuickPane { } else { g2d.setPaint(null); } - GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); + GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, (double)d.width - 1, (double) d.height - 1)); } public Dimension getPreferredSize() { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index 53802507c8..57d1d457f6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.ui.util.UIUtil; import com.fr.general.ComparatorUtils; import com.fr.general.log.Log4jConfig; import com.fr.log.FineLoggerFactory; @@ -41,66 +42,66 @@ import java.util.Date; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; public class DesignerLogHandler { - + private final SimpleDateFormat LOG_SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - + private static final int GAP_X = -150; - + private static final int INFO_GAP_Y = -60; - + private static final int ERRO_GAP_Y = -40; - + private static final int SERVER_GAP_Y = -20; - + public static DesignerLogHandler getInstance() { - + return HOLDER.singleton; } - + private static class HOLDER { - + private static DesignerLogHandler singleton = new DesignerLogHandler(); } - + // 所有的面板 private LogHandlerBar caption; - + private JCheckBoxMenuItem showInfo; - + private JCheckBoxMenuItem showError; - + private JCheckBoxMenuItem showServer; - + private LogHandlerArea logHandlerArea; - + public DesignerLogHandler() { - + logHandlerArea = new LogHandlerArea(); caption = new LogHandlerBar(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Log")); - + caption.addClearListener(new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { - + logHandlerArea.jTextArea.setText(""); caption.clearMessage(); } }); caption.addSelectedListener(new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { - + logHandlerArea.jTextArea.requestFocus(); logHandlerArea.jTextArea.selectAll(); } }); ItemListener itemlistener = new ItemListener() { - + @Override public void itemStateChanged(ItemEvent e) { - + logHandlerArea.jTextArea.setText(""); caption.clearMessage(); } @@ -112,12 +113,12 @@ public class DesignerLogHandler { showServer = new JCheckBoxMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Log_Level_Error"), true); showServer.addItemListener(itemlistener); caption.addSetListener(new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { - + JPopupMenu jPopupMenu = new JPopupMenu(); - + int logLevelInt = Log4jConfig.getInstance().getRootLevel().toInt(); if (logLevelInt <= DesignerLogger.INFO_INT) { jPopupMenu.add(showInfo); @@ -135,72 +136,73 @@ public class DesignerLogHandler { } }); } - + public JComponent getLogHandlerArea() { - + return logHandlerArea; } - + public JComponent getCaption() { - + return caption; } - + public void printRemoteLog(String message, Level level, Date date) { - + logHandlerArea.printStackTrace(message, level, date); } - + private class LogHandlerArea extends JPanel { - + private static final long serialVersionUID = 8215630927304621660L; - + private JTextPane jTextArea; - + private JPopupMenu popup; - + private UIMenuItem selectAll; - + private UIMenuItem copy; - + private UIMenuItem clear; - + private LogHandlerArea() { - + jTextArea = initLogJTextArea(); this.setLayout(FRGUIPaneFactory.createBorderLayout()); UIScrollPane js = new UIScrollPane(jTextArea); this.add(js, BorderLayout.CENTER); this.setPreferredSize(new Dimension(super.getPreferredSize().width, 150)); - + jTextArea.setEditable(false); jTextArea.setBackground(Color.WHITE); - + popup = new JPopupMenu(); selectAll = new UIMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_All")); selectAll.addActionListener(popupListener); selectAll.setIcon(BaseUtils.readIcon("/com/fr/design/images/log/selectedall.png")); popup.add(selectAll); - + copy = new UIMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy")); copy.addActionListener(popupListener); copy.setIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); popup.add(copy); - + clear = new UIMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Clear_All")); clear.addActionListener(popupListener); clear.setIcon(BaseUtils.readIcon("/com/fr/design/images/log/clear.png")); popup.add(clear); - + selectAll.setAccelerator(KeyStroke.getKeyStroke('A', DEFAULT_MODIFIER)); copy.setAccelerator(KeyStroke.getKeyStroke('C', DEFAULT_MODIFIER)); clear.setAccelerator(KeyStroke.getKeyStroke('L', DEFAULT_MODIFIER)); - + jTextArea.addMouseListener(new MouseAdapter() { - + // check for right click + @Override public void mousePressed(MouseEvent event) { - + if (event.getButton() == MouseEvent.BUTTON3) { popup.show(jTextArea, event.getX(), event.getY()); checkEnabled(); @@ -208,9 +210,9 @@ public class DesignerLogHandler { } }); } - + private JTextPane initLogJTextArea() { - + final JTextPane resultPane = new JTextPane(); InputMap inputMap = resultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction); @@ -218,18 +220,19 @@ public class DesignerLogHandler { inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, DEFAULT_MODIFIER), "clear"); ActionMap actionMap = resultPane.getActionMap(); actionMap.put("clear", new AbstractAction() { - + + @Override public void actionPerformed(ActionEvent evt) { - + resultPane.setText(""); caption.clearMessage(); } }); return resultPane; } - + public void printStackTrace(LoggingEvent event) { - + int intLevel = event.getLevel().toInt(); Date date = new Date(event.getTimeStamp()); ThrowableInformation information = event.getThrowableInformation(); @@ -241,9 +244,9 @@ public class DesignerLogHandler { printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable()); } } - + public void printStackTrace(String message, Level level, Date date) { - + int intLevel = level.toInt(); if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) { printMessage(message, intLevel, date); @@ -252,32 +255,36 @@ public class DesignerLogHandler { } else if (intLevel == DesignerLogger.WARN_INT && showServer.isSelected()) { printMessage(message, intLevel, date); } - + } - + private void printMessage(String message, int intLevel, Date date) { - + printMessage(message, intLevel, date, null); } - - private void printMessage(String msg, int intLevel, Date date, Throwable e) { - - this.log(LOG_SIMPLE_DATE_FORMAT.format(date) + "\n", 0); - String message = appendLocaleMark(msg, intLevel); - this.log(message, intLevel); - setMessage(message, intLevel); - if (e == null) { - return; - } - - StackTraceElement[] traceElements = e.getStackTrace(); - for (int i = 0; i < traceElements.length; i++) { - this.log("\t" + "at " + traceElements[i].toString() + "\n", 0); - } + + private void printMessage(final String msg, final int intLevel, final Date date, final Throwable e) { + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + LogHandlerArea.this.log(LOG_SIMPLE_DATE_FORMAT.format(date) + "\n", 0); + String message = appendLocaleMark(msg, intLevel); + LogHandlerArea.this.log(message, intLevel); + setMessage(message, intLevel); + if (e == null) { + return; + } + + StackTraceElement[] traceElements = e.getStackTrace(); + for (StackTraceElement traceElement : traceElements) { + LogHandlerArea.this.log("\t" + "at " + traceElement.toString() + "\n", 0); + } + } + }); } - + private void log(String str, int style) { - + SimpleAttributeSet attrSet = new SimpleAttributeSet(); if (style == DesignerLogger.ERROR_INT) { StyleConstants.setForeground(attrSet, new Color(247, 148, 29)); @@ -299,9 +306,9 @@ public class DesignerLogHandler { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } - + private String appendLocaleMark(String str, int style) { - + if (style == DesignerLogger.ERROR_INT) { str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":" + str + "\n"; } else if (style == DesignerLogger.WARN_INT) { @@ -311,9 +318,9 @@ public class DesignerLogHandler { } return str; } - + private void setMessage(String message, int level) { - + LogMessageBar.getInstance().setMessage(message); if (level == DesignerLogger.INFO_INT && showInfo.isSelected()) { caption.infoAdd(); @@ -323,31 +330,32 @@ public class DesignerLogHandler { caption.serverAdd(); } } - + private void checkEnabled() { - + this.selectAll.setEnabled(true); this.copy.setEnabled(true); this.clear.setEnabled(true); - + if (ComparatorUtils.equals(this.jTextArea.getText(), "")) { this.selectAll.setEnabled(false); this.clear.setEnabled(false); } - + if (ComparatorUtils.equals(this.jTextArea.getSelectionStart(), this.jTextArea.getSelectionEnd())) { this.copy.setEnabled(false); } - + if (this.jTextArea.getSelectionStart() == 0 && ComparatorUtils.equals(this.jTextArea.getSelectionEnd(), this.jTextArea.getText().length())) { this.selectAll.setEnabled(false); } } - + ActionListener popupListener = new ActionListener() { - + + @Override public void actionPerformed(ActionEvent evt) { - + if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.selectAll.getText())) { LogHandlerArea.this.jTextArea.selectAll(); } else if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.copy.getText())) { @@ -358,6 +366,6 @@ public class DesignerLogHandler { } } }; - + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java index 5a4ba1edaf..bbb9eed346 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java @@ -69,7 +69,7 @@ public class LogHandlerBarUI extends ComponentUI implements MouseListener, Focus int w = button.getWidth(); int h = button.getHeight(); Graphics2D g2d = (Graphics2D) g; - GradientPaint gp = new GradientPaint(1, 1, darkColor, 1, h - 1, darkColor); + GradientPaint gp = new GradientPaint(1, 1, darkColor, 1, (float)(h - 1), darkColor); g2d.setPaint(gp); g2d.fillRect(0, 0, w, h); } 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/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 262dbe6d57..d916d967fc 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -54,6 +54,7 @@ import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.remote.action.RemoteDesignAuthManagerAction; import com.fr.design.update.actions.SoftwareUpdateAction; import com.fr.design.utils.ThemeUtils; @@ -70,6 +71,8 @@ import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventType; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; import org.jetbrains.annotations.Nullable; @@ -524,7 +527,7 @@ public abstract class ToolBarMenuDock { * @return 帮组菜单的子菜单 */ public ShortCut[] createHelpShortCuts() { - java.util.List shortCuts = new ArrayList(); + final java.util.List shortCuts = new ArrayList(); shortCuts.add(new WebDemoAction()); // 英文,把 video 和帮助文档放到 Help 下面 if (GeneralContext.getLocale().equals(Locale.US)) { @@ -541,7 +544,13 @@ public abstract class ToolBarMenuDock { shortCuts.add(SeparatorDef.DEFAULT); if (DesignerEnvManager.getEnvManager().isOpenDebug()) { - shortCuts.add(new FineUIAction()); + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + shortCuts.add(new FineUIAction()); + } + }, SupportOSImpl.FINEUI); + } shortCuts.add(new AboutAction()); 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 4f447eaef0..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,8 @@ 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; import com.fr.design.file.TemplateTreePane; @@ -25,9 +27,9 @@ import com.fr.workspace.server.vcs.git.config.GcConfig; import javax.swing.Icon; import javax.swing.border.EmptyBorder; import java.awt.Color; -import java.util.Date; -import static com.fr.stable.StableUtils.pathJoin; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** * Created by XiaXiang on 2019/4/17. @@ -49,10 +51,10 @@ public class VcsHelper implements JTemplateActionListener { public final static int OFFSET = 2; private static final int MINUTE = 60 * 1000; private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10"; - private static final VcsHelper instance = new VcsHelper(); + private static final VcsHelper INSTANCE = new VcsHelper(); public static VcsHelper getInstance() { - return instance; + return INSTANCE; } private int containsFolderCounts() { @@ -111,7 +113,7 @@ public class VcsHelper implements JTemplateActionListener { if (configManager.isSaveCommit() && StringUtils.isNotBlank(entity.getCommitMsg())) { return false; } - return new Date().getTime() - entity.getTime().getTime() < DesignerEnvManager.getEnvManager().getVcsConfigManager().getSaveInterval() * MINUTE; + return System.currentTimeMillis() - entity.getTime().getTime() < DesignerEnvManager.getEnvManager().getVcsConfigManager().getSaveInterval() * MINUTE; } public boolean needInit() { @@ -125,7 +127,8 @@ public class VcsHelper implements JTemplateActionListener { * @param jt */ public void fireVcs(final JTemplate jt) { - new Thread(new Runnable() { + ExecutorService fireVcs = Executors.newSingleThreadExecutor(new NamedThreadFactory("fireVcs")); + fireVcs.execute(new Runnable() { @Override public void run() { @@ -152,8 +155,8 @@ public class VcsHelper implements JTemplateActionListener { } } - }).start(); - + }); + fireVcs.shutdown(); } @@ -169,7 +172,9 @@ public class VcsHelper implements JTemplateActionListener { */ @Override public void templateSaved(JTemplate jt) { - if (needInit() && DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() && !FineClusterConfig.getInstance().isCluster()) { + if (needInit() + && DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() + && !FineClusterConfig.getInstance().isCluster()) { fireVcs(jt); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java index 15d8bae63e..8216ad5735 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java @@ -31,7 +31,7 @@ import java.util.List; public class FileVersionDialog extends UIDialog { - public static final long DELAY = 24 * 60 * 60 * 1000; + public static final long DELAY = 24 * 60 * 60 * 1000L; private UIButton okBtn; private UIButton cancelBtn; private DateEditor dateEditor; 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/DatabaseDialogAction.java b/designer-base/src/main/java/com/fr/design/os/impl/DatabaseDialogAction.java new file mode 100644 index 0000000000..7db0004937 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/DatabaseDialogAction.java @@ -0,0 +1,77 @@ +package com.fr.design.os.impl; + +import com.fr.config.ServerPreferenceConfig; +import com.fr.design.data.datapane.connect.ConnectionManagerPane; +import com.fr.design.dcm.UniversalDatabaseOpener; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrame; +import com.fr.file.ConnectionConfig; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.transaction.CallBackAdaptor; +import com.fr.transaction.Configurations; +import com.fr.transaction.WorkerFacade; +import static com.fr.design.actions.server.ConnectionListAction.doWithDatasourceManager; + +/** + * 数据连接窗口 + * @author pengda + * @date 2019/10/9 + */ +public class DatabaseDialogAction implements OSBasedAction { + + @Override + public void execute(Object... objects) { + if (ServerPreferenceConfig.getInstance().isUseUniverseDBM() && !OperatingSystem.isLinux()) { + UniversalDatabaseOpener.showUniverseDatabaseDialog(); + } else { + openDesignDatabaseManager(); + } + } + + private void openDesignDatabaseManager() { + DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); + final ConnectionConfig datasourceManager = ConnectionConfig.getInstance(); + final ConnectionManagerPane databaseManagerPane = new ConnectionManagerPane() { + public void complete() { + ConnectionConfig connectionConfig = datasourceManager.mirror(); + populate(connectionConfig); + } + + protected void renameConnection(String oldName, String newName) { + datasourceManager.renameConnection(oldName, newName); + } + }; + final BasicDialog databaseListDialog = databaseManagerPane.showLargeWindow(designerFrame, null); + databaseListDialog.addDialogActionListener(new DialogActionAdapter() { + public void doOk() { + if (!databaseManagerPane.isNamePermitted()) { + databaseListDialog.setDoOKSucceed(false); + return; + } + Configurations.modify(new WorkerFacade(ConnectionConfig.class) { + @Override + public void run() { + databaseManagerPane.update(datasourceManager); + } + }.addCallBack(new CallBackAdaptor() { + @Override + public boolean beforeCommit() { + //如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面 + return doWithDatasourceManager(datasourceManager, databaseManagerPane, databaseListDialog); + } + + @Override + public void afterCommit() { + DesignerContext.getDesignerBean("databasename").refreshBeanElement(); + } + })); + } + }); + databaseListDialog.setVisible(true); + } + + +} 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 new file mode 100644 index 0000000000..1696e6ce8a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/DemoAction.java @@ -0,0 +1,58 @@ +package com.fr.design.os.impl; + +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StableUtils; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.OSBasedAction; + +import java.io.IOException; +/** + * @author pengda + * @date 2019/10/9 + */ +public class DemoAction implements OSBasedAction { + + @Override + public void execute(Object... objects) { + String installHome = StableUtils.getInstallHome(); + if (installHome == null) { + FineLoggerFactory.getLogger().error("Can not find the install home, please check it."); + return; + } + + 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 demo"); + } + + if (OperatingSystem.isMacos()) { + ProcessBuilder builder = new ProcessBuilder(); + builder.command("open", "-a", executorPath, "--args", "demo"); + try { + builder.start(); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } else if(OperatingSystem.isWindows()){ + // ProcessBuilder这种方式在window下报错:系统找不到指定文件 + Runtime rt = Runtime.getRuntime(); + try { + rt.exec(executorPath); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + }else{ + //先用和win一样的方式 + Runtime rt = Runtime.getRuntime(); + try { + rt.exec(executorPath); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java b/designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java new file mode 100644 index 0000000000..3f2f097283 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java @@ -0,0 +1,30 @@ +package com.fr.design.os.impl; + +import com.fr.config.ServerPreferenceConfig; +import com.fr.design.extra.WebViewDlgHelper; +import com.fr.design.upm.UpmFinder; +import com.fr.design.utils.DesignUtils; +import com.fr.stable.os.Arch; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.OSBasedAction; + +/** + * 插件管理窗口 + * @author pengda + * @date 2019/10/9 + */ +public class PMDialogAction implements OSBasedAction { + private static String PLUGIN_MANAGER_ROUTE = "#management/plugin"; + @Override + public void execute(Object... objects) { + if(Arch.getArch() == Arch.ARM){ + DesignUtils.visitEnvServerByParameters( PLUGIN_MANAGER_ROUTE,null,null); + return; + } + if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM() && !OperatingSystem.isLinux()) { + UpmFinder.showUPMDialog(); + } else { + WebViewDlgHelper.createPluginDialog(); + } + } +} 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 new file mode 100644 index 0000000000..d80fad5546 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java @@ -0,0 +1,82 @@ +package com.fr.design.os.impl; + +import com.fr.log.FineLoggerFactory; +import com.fr.stable.ArrayUtils; +import com.fr.stable.StableUtils; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.OSBasedAction; +import java.io.File; +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; + if (installHome == null) { + installHome = StableUtils.getInstallHome(); + } + try{ + if (OperatingSystem.isMacos()) { + restartInMacOS(installHome, filesToBeDelete); + } else if(OperatingSystem.isWindows()){ + restartInWindows(installHome, filesToBeDelete); + }else{ + //增加一个Linux系统 + restartInLinux(installHome,filesToBeDelete); + } + }catch(Exception e){ + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + + } + + private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception { + ProcessBuilder builder = new ProcessBuilder(); + List commands = new ArrayList(); + commands.add("open"); + commands.add(installHome + File.separator + "bin" + File.separator + "restart.app"); + if (ArrayUtils.isNotEmpty(filesToBeDelete)) { + commands.add("--args"); + commands.add(StableUtils.join(filesToBeDelete, "+")); + } + builder.command(commands); + builder.start(); + } + + private static void restartInWindows(String installHome, String[] filesToBeDelete) throws Exception { + ProcessBuilder builder = new ProcessBuilder(); + List commands = new ArrayList(); + commands.add(installHome + File.separator + "bin" + File.separator + "restart.exe"); + if (ArrayUtils.isNotEmpty(filesToBeDelete)) { + commands.add(StableUtils.join(filesToBeDelete, "+")); + } + builder.command(commands); + builder.start(); + } + + private static void restartInLinux(String installHome, String[] filesToBeDelete) throws Exception { + ProcessBuilder builder = new ProcessBuilder(); + List commands = new ArrayList(); + commands.add(installHome + File.separator + "bin" + File.separator + "restart"); + if (ArrayUtils.isNotEmpty(filesToBeDelete)) { + commands.add(StableUtils.join(filesToBeDelete, "+")); + } + builder.command(commands); + builder.start(); + } + + + + + + + +} diff --git a/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java b/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java new file mode 100644 index 0000000000..31aac9aa11 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java @@ -0,0 +1,63 @@ +package com.fr.design.os.impl; + +import com.fr.base.FRContext; +import com.fr.general.GeneralContext; +import com.fr.stable.os.Arch; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.SupportOS; +import com.fr.workspace.WorkContext; + +/** + * @author pengda + * @date 2019/10/9 + */ +public enum SupportOSImpl implements SupportOS { + + /** + * ARM下屏蔽登录 + */ + USERINFOPANE{ + public boolean support(){ + return Arch.getArch() != Arch.ARM; + } + }, + /** + * Linux系统屏蔽透明度 + */ + OPACITY{ + public boolean support(){ + return !OperatingSystem.isLinux(); + } + }, + /** + * Linux系统屏蔽FineUI选项 + */ + FINEUI{ + public boolean support(){ + return !OperatingSystem.isLinux(); + } + }, + /** + * 自动更新推送 + */ + AUTOPUSHUPDATE{ + @Override + public boolean support() { + boolean isLocalEnv = WorkContext.getCurrent().isLocal(); + boolean isChineseEnv = GeneralContext.isChineseEnv(); + boolean isLinux = OperatingSystem.isLinux(); + // 远程设计和非中文环境以及Linux环境,都不生效 + return isLocalEnv && isChineseEnv && !isLinux; + } + }, + /** + * BBS窗口 + */ + BBSDIALOG{ + @Override + public boolean support() { + return FRContext.isChineseEnv() && !OperatingSystem.isMacos() && Arch.getArch() != Arch.ARM; + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/os/impl/UpdateDialogAction.java b/designer-base/src/main/java/com/fr/design/os/impl/UpdateDialogAction.java new file mode 100644 index 0000000000..64f8f21120 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/UpdateDialogAction.java @@ -0,0 +1,25 @@ +package com.fr.design.os.impl; + +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.update.ui.dialog.UpdateMainDialog; +import com.fr.design.utils.DesignUtils; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.OSBasedAction; + +/** + * 更新升级窗口 + * @author pengda + * @date 2019/10/9 + */ +public class UpdateDialogAction implements OSBasedAction { + private static String UPDATE_ROUTE = "#management/backup"; + @Override + public void execute(Object... objects) { + if(!OperatingSystem.isLinux()) { + UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); + dialog.showDialog(); + }else{ + DesignUtils.visitEnvServerByParameters( UPDATE_ROUTE,null,null); + } + } +} 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 1b8b71dc4f..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(); @@ -317,10 +326,9 @@ public abstract class AbstractManagerPane extends BasicPane { for (RemoteDesignMember member : addingMembers) { // 如果包含在右侧列表中,那么左侧列表默认选中 if (addedMembers.contains(member)) { - member.setAuthority(true); member.setSelected(true); - } else { - member.setAuthority(false); + } + else { member.setSelected(false); } addingListModel.addElement(member); @@ -351,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); @@ -377,6 +389,7 @@ public abstract class AbstractManagerPane extends BasicPane { @Override protected void done() { + referAddingMemberList(); addToMemberList(); } }; @@ -404,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/WatermarkPane.java b/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java index a7f78e1170..07ec40bfee 100644 --- a/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java +++ b/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java @@ -23,6 +23,9 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import javax.swing.JDialog; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; import java.awt.Dimension; import java.awt.BorderLayout; import java.awt.Color; @@ -30,6 +33,13 @@ import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.awt.event.MouseListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.FocusAdapter; +import java.awt.Dialog; +import java.awt.FlowLayout; + /** * Created by plough on 2018/5/15. @@ -49,6 +59,13 @@ public class WatermarkPane extends BasicPane { private UISpinner verticalGapSpinner; // 文字颜色 private NewColorSelectPane colorPane; + //间距超过限制消息 + private UILabel message; + + //横向间距最小值 + public static final int HORIZONTAL_GAP_MIX = 100; + //纵向间距最小值 + public static final int VERTICAL_GAP_MIX = 50; private static final Dimension SPINNER_DIMENSION = new Dimension(75, 20); @@ -57,6 +74,7 @@ public class WatermarkPane extends BasicPane { } private void initComponents() { + message = new UILabel(); this.setBorder(BorderFactory.createEmptyBorder(4, 4, -5, 4)); this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -93,7 +111,7 @@ public class WatermarkPane extends BasicPane { public WatermarkAttr update() { WatermarkAttr watermark = new WatermarkAttr(); watermark.setText(formulaPane.getUITextField().getText()); - watermark.setFontSize((int)fontSizeComboBox.getSelectedItem()); + watermark.setFontSize((int) fontSizeComboBox.getSelectedItem()); watermark.setHorizontalGap((int) horizontalGapSpinner.getValue()); watermark.setVerticalGap((int) verticalGapSpinner.getValue()); watermark.setColor(colorPane.getColor()); @@ -109,7 +127,7 @@ public class WatermarkPane extends BasicPane { this.formulaPane = formulaPane; } - protected UIScrollPane initRightPane(){ + protected UIScrollPane initRightPane() { formulaPane = new TinyFormulaPane(); fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); fontSizeComboBox.setEditable(true); @@ -117,7 +135,17 @@ public class WatermarkPane extends BasicPane { verticalGapSpinner = new UnsignedIntUISpinner(50, Integer.MAX_VALUE, 1, 100); horizontalGapSpinner.setPreferredSize(SPINNER_DIMENSION); verticalGapSpinner.setPreferredSize(SPINNER_DIMENSION); - JPanel fontSizeTypePane = new JPanel(new BorderLayout(10,0)); + message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0)); + //失去焦点时要判断是否要弹出提示 + horizontalGapSpinner.getTextField().addFocusListener( + createFocusListener4GapNumberField(horizontalGapSpinner, HORIZONTAL_GAP_MIX, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Horizontal_Gap_Over_Warning"))); + verticalGapSpinner.getTextField().addFocusListener(createFocusListener4GapNumberField(verticalGapSpinner, VERTICAL_GAP_MIX, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Vertical_Gap_Over_Warning"))); + + //next 按钮 释放时也要判断是否要弹出提示 + horizontalGapSpinner.getNextButton().addMouseListener(createMouseListener4GapNextButton(horizontalGapSpinner, HORIZONTAL_GAP_MIX, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Horizontal_Gap_Over_Warning"))); + verticalGapSpinner.getNextButton().addMouseListener(createMouseListener4GapNextButton(verticalGapSpinner, VERTICAL_GAP_MIX, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Vertical_Gap_Over_Warning"))); + + JPanel fontSizeTypePane = new JPanel(new BorderLayout(10, 0)); fontSizeTypePane.add(fontSizeComboBox, BorderLayout.CENTER); //水印间距面板 @@ -144,18 +172,18 @@ public class WatermarkPane extends BasicPane { JPanel rightContentPane = TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{ {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Watermark_Text")), formulaPane}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Font_Size")), fontSizeTypePane}, - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Watermark_Gap")),watermarkGapPane }, - {null,watermarkGapTipsPane }, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Watermark_Gap")), watermarkGapPane}, + {null, watermarkGapTipsPane}, {colorLabelPane, colorPane}, }, rowSize, columnSize, 10); rightContentPane.setBorder(BorderFactory.createEmptyBorder(15, 12, 10, 12)); UIScrollPane configPane = new UIScrollPane(rightContentPane); - configPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Config"),null)); + configPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Config"), null)); return configPane; } - protected void populateFontSize(int fontSize){ + protected void populateFontSize(int fontSize) { this.fontSizeComboBox.setSelectedItem(fontSize); this.fontSizeComboBox.addItemListener(new ItemListener() { @Override @@ -165,7 +193,7 @@ public class WatermarkPane extends BasicPane { }); } - protected void populateWatermarkGap(WatermarkAttr watermark){ + protected void populateWatermarkGap(WatermarkAttr watermark) { this.horizontalGapSpinner.setValue(watermark.getHorizontalGap()); this.horizontalGapSpinner.addUISpinnerFocusListenner(new FocusListener() { @@ -195,7 +223,7 @@ public class WatermarkPane extends BasicPane { }); } - protected void paintPreviewPane(){ + protected void paintPreviewPane() { watermarkPreviewPane.repaint(update()); } @@ -235,4 +263,65 @@ public class WatermarkPane extends BasicPane { protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark"); } + + /** + * 创建水印间距文本段焦点监听器 + * + * @return + */ + private FocusListener createFocusListener4GapNumberField(final UISpinner spinner, final int limitMinValue, final String messageStr) { + return new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + if (!spinner.isLessMinValue()) { + return; + } + spinner.resetLessMinValue(); + createGapDialog(new StringBuilder(messageStr).append(limitMinValue).toString()); + } + }; + } + + /** + * 创建水印间距微调器 NextButton 的鼠标释放监听器 + * + * @param messageStr 提示消息 + * @param limitMinValue 限制的最小值 + * @return + */ + private MouseListener createMouseListener4GapNextButton(final UISpinner spinner, final int limitMinValue, final String messageStr) { + MouseAdapter mouseAdapter = new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + if (!spinner.isLessMinValue()) { + return; + } + spinner.resetLessMinValue(); + createGapDialog(new StringBuilder(messageStr).append(limitMinValue).toString()); + } + }; + return mouseAdapter; + } + + /** + * 创建超过水印间距限制的对话框 + * + * @param messageStr 提示消息 + */ + private void createGapDialog(String messageStr) { + JDialog dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(WatermarkPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), true); + dialog.setSize(new Dimension(268, 118)); + message.setText(messageStr); + JPanel upPane = new JPanel(); + UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon")); + upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); + upPane.add(uiLabel); + upPane.add(message); + dialog.add(upPane); + dialog.setResizable(false); + dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(WatermarkPane.this)); + dialog.setVisible(true); + dialog.dispose(); + } + } 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/scrollruler/VerticalRulerUI.java b/designer-base/src/main/java/com/fr/design/scrollruler/VerticalRulerUI.java index 3e0a9eb068..2cd482e1e3 100644 --- a/designer-base/src/main/java/com/fr/design/scrollruler/VerticalRulerUI.java +++ b/designer-base/src/main/java/com/fr/design/scrollruler/VerticalRulerUI.java @@ -20,7 +20,7 @@ public class VerticalRulerUI extends RulerUI{ @Override protected void paintRuler(Graphics g, int showText, int extra, Dimension size, int ratio) { int k = pxToLength(extra) * ratio; - for (int i = k; i < (pxToLength(size.height + extra) + 1) * ratio; i++) { + for (int i = k; i < (pxToLength( (double)size.height + extra) + 1) * ratio; i++) { g.setColor(BaseRuler.UNIT_SIGN_COLOR); if (i % BaseRuler.SCALE_10 == 0) { double times = (double) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution() / ScreenResolution.getScreenResolution(); @@ -44,7 +44,7 @@ public class VerticalRulerUI extends RulerUI{ @Override protected void paintPTRuler(Graphics g, int extra, Dimension size, int unit) { int k = pxToLength(extra); - for (int i = unit * (k/unit); i < pxToLength(size.height + extra); i += unit) { + for (int i = unit * (k/unit); i < pxToLength((double)size.height + extra); i += unit) { g.setColor(BaseRuler.UNIT_SIGN_COLOR); if (i % BaseRuler.SCALE_100 == 0) { GraphHelper.drawLine(g, size.width, toPX(i) - extra, 0, toPX(i) - extra); diff --git a/designer-base/src/main/java/com/fr/design/style/background/impl/PatternBackgroundPane.java b/designer-base/src/main/java/com/fr/design/style/background/impl/PatternBackgroundPane.java index ffb4e1eb0b..886076ca08 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/impl/PatternBackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/style/background/impl/PatternBackgroundPane.java @@ -159,15 +159,15 @@ public class PatternBackgroundPane extends BPane { Dimension d = getSize(); this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, - d.width - 1, d.height - 1)); + d.width - 1d, d.height - 1d)); if (this.pIndex == patternIndex) {// it's selected. g2d.setPaint(new Color(255, 51, 0)); } else { g2d.setPaint(Color.gray); } - GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, - d.height - 1)); + GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1d, + d.height - 1d)); } public Dimension getPreferredSize() { diff --git a/designer-base/src/main/java/com/fr/design/style/background/impl/TextureBackgroundPane.java b/designer-base/src/main/java/com/fr/design/style/background/impl/TextureBackgroundPane.java index 8c99a89cdd..3dd59bd5b4 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/impl/TextureBackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/style/background/impl/TextureBackgroundPane.java @@ -152,8 +152,8 @@ public class TextureBackgroundPane extends BPane { Dimension d = getSize(); g2d.setPaint(this.buttonTexturePaint); - GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1, - d.height - 1)); + GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1d, + d.height - 1d)); if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's // selected. @@ -161,8 +161,8 @@ public class TextureBackgroundPane extends BPane { } else { g2d.setPaint(Color.gray); } - GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, - d.height - 1)); + GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1d, + d.height - 1d)); } public Dimension getPreferredSize() { 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/style/color/CustomChooserPanel.java b/designer-base/src/main/java/com/fr/design/style/color/CustomChooserPanel.java index 79ecdc9461..6d8d267445 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/CustomChooserPanel.java +++ b/designer-base/src/main/java/com/fr/design/style/color/CustomChooserPanel.java @@ -314,8 +314,8 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec * @param p The point where the MouseEvent occurred. */ private void updateH(Point p) { - float s = (IMG_WIDTH - p.x * 1f) / IMG_WIDTH; - float b = (IMG_HEIGHT - p.y * 1f) / IMG_HEIGHT; + double s = (IMG_WIDTH - p.x * 1D) / IMG_WIDTH; + double b = (IMG_HEIGHT - p.y * 1D) / IMG_HEIGHT; // Avoid two changes to the model by changing internalChange to true. internalChange = true; @@ -332,8 +332,8 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec * @param p The point where the MouseEvent occurred. */ private void updateS(Point p) { - float h = p.x * 1f / IMG_WIDTH; - float b = (IMG_HEIGHT - p.y * 1f) / IMG_HEIGHT; + double h = p.x * 1D / IMG_WIDTH; + double b = (IMG_HEIGHT - p.y * 1D) / IMG_HEIGHT; internalChange = true; hSpinner.setValue(new Integer((int) (h * H_MAX))); @@ -349,8 +349,8 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec * @param p The point where the MouseEvent occurred. */ private void updateB(Point p) { - float h = p.x * 1f / IMG_WIDTH; - float s = (IMG_HEIGHT - p.y * 1f) / IMG_HEIGHT; + double h = p.x * 1D / IMG_WIDTH; + double s = (IMG_HEIGHT - p.y * 1D) / IMG_HEIGHT; internalChange = true; hSpinner.setValue(new Integer((int) (h * H_MAX))); @@ -523,9 +523,9 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec private void adjustHSLValue(float[] hsbVals) { if (!spinnerTrigger) { - hSpinner.setValue(new Integer((int) (hsbVals[0] * HSPINNER_VALUE))); - sSpinner.setValue(new Integer((int) (hsbVals[1] * SSPINNER_VALUE))); - bSpinner.setValue(new Integer((int) (hsbVals[2] * LSPINNER_VALUE))); + hSpinner.setValue(new Integer((int) ((double) hsbVals[0] * HSPINNER_VALUE))); + sSpinner.setValue(new Integer((int) ((double) hsbVals[1] * SSPINNER_VALUE))); + bSpinner.setValue(new Integer((int) ((double) hsbVals[2] * LSPINNER_VALUE))); } switch (locked) { case HLOCKED: @@ -534,9 +534,9 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec } if (!handlingMouse) { gradientPoint.x = (int) ((1 - - ((Number) sSpinner.getValue()).intValue() / SSPINNER_VALUE) * IMG_WIDTH); + - ((Number) sSpinner.getValue()).intValue() / (double) SSPINNER_VALUE) * IMG_WIDTH); gradientPoint.y = (int) ((1 - - ((Number) bSpinner.getValue()).intValue() / LSPINNER_VALUE) * IMG_HEIGHT); + - ((Number) bSpinner.getValue()).intValue() / (double) LSPINNER_VALUE) * IMG_HEIGHT); } break; case SLOCKED: @@ -544,9 +544,9 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec slider.setValue(((Number) sSpinner.getValue()).intValue()); } if (!handlingMouse) { - gradientPoint.x = (int) (((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE * IMG_WIDTH); + gradientPoint.x = (int) (((Number) hSpinner.getValue()).intValue() / (double) HSPINNER_VALUE * IMG_WIDTH); gradientPoint.y = (int) ((1 - - ((Number) bSpinner.getValue()).intValue() / LSPINNER_VALUE) * IMG_HEIGHT); + - ((Number) bSpinner.getValue()).intValue() / (double) LSPINNER_VALUE) * IMG_HEIGHT); } break; case BLOCKED: @@ -554,18 +554,18 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec slider.setValue(((Number) bSpinner.getValue()).intValue()); } if (!handlingMouse) { - gradientPoint.x = (int) (((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE * IMG_WIDTH); + gradientPoint.x = (int) (((Number) hSpinner.getValue()).intValue() / (double) HSPINNER_VALUE * IMG_WIDTH); gradientPoint.y = (int) ((1 - - ((Number) sSpinner.getValue()).intValue() / SSPINNER_VALUE) * IMG_HEIGHT); + - ((Number) sSpinner.getValue()).intValue() / (double) SSPINNER_VALUE) * IMG_HEIGHT); } break; } } private void updateImageAndTrack() { - float h = ((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE; - float s = ((Number) sSpinner.getValue()).intValue() / SSPINNER_VALUE; - float b = ((Number) bSpinner.getValue()).intValue() / LSPINNER_VALUE; + float h = (float) (((Number) hSpinner.getValue()).intValue() / (double) HSPINNER_VALUE); + float s = (float) (((Number) sSpinner.getValue()).intValue() / (double) SSPINNER_VALUE); + float b = (float) (((Number) bSpinner.getValue()).intValue() / (double) LSPINNER_VALUE); spinnerTrigger = true; getColorSelectionModel().setSelectedColor(new Color(Color.HSBtoRGB(h, s, b))); @@ -837,12 +837,12 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec private void updateHLockImage() { int index = 0; int[] pix = new int[IMG_WIDTH * IMG_HEIGHT]; - float hValue = ((Number) hSpinner.getValue()).intValue() / HSPINNER_VALUE; + float hValue = (float)(((Number) hSpinner.getValue()).intValue() / (double) HSPINNER_VALUE ); for (int j = 0; j < IMG_HEIGHT; j++) { for (int i = 0; i < IMG_WIDTH; i++) { - pix[index++] = Color.HSBtoRGB(hValue, (IMG_WIDTH - i * 1f) / IMG_WIDTH, - (IMG_HEIGHT - j * 1f) / IMG_HEIGHT) | (BINARY_FOR_EIGHT << TWENTY_FOUR); + pix[index++] = Color.HSBtoRGB(hValue, (float) ((IMG_WIDTH - i * 1D) / IMG_WIDTH), + (float) ((IMG_HEIGHT - j * 1D) / IMG_HEIGHT)) | (BINARY_FOR_EIGHT << TWENTY_FOUR); } } @@ -1076,4 +1076,4 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec public void colorSetted(ColorCell cc) { } -} \ No newline at end of file +} 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 new file mode 100644 index 0000000000..eb25ccea30 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java @@ -0,0 +1,103 @@ +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.log.FineLoggerFactory; +import com.fr.stable.CommonUtils; +import com.fr.stable.ProjectLibrary; +import com.fr.stable.StableUtils; +import com.fr.stable.project.ProjectConstants; + +import java.io.File; +import java.io.IOException; + +/** + * @author Bryant + * @version 10.0 + * Created by Bryant on 2019-10-09 + */ +public class RecoverForDesigner implements Recover { + + private final String installHome = StableUtils.getInstallHome(); + + @Override + public boolean recover() { + try{ + 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("Recover error for designer", e); + return false; + } + } + + @Override + public boolean backup() { + //jar包备份文件的目录为"backup/"+jar包当前版本号 + String todayBackupDir = StableUtils.pathJoin(installHome, UpdateConstants.DESIGNER_BACKUP_DIR, (GeneralUtils.readBuildNO())); + String envHome = ProjectLibrary.getInstance().getLibHome(); + backupFilesFromInstallEnv(envHome, todayBackupDir); + backupFilesFromInstallLib(installHome, todayBackupDir); + try { + 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) { + UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage()); + FineLoggerFactory.getLogger().error(exception.getMessage(),exception); + return false; + } + } + + private void backupFilesFromInstallEnv(String envHome, String todayBackupDir) { + try { + 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"); + } + } + + private void backupFilesFromInstallLib(String installHome, String todayBackupDir) { + try { + CommonUtils.mkdirs(new File(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"); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/update/actions/SoftwareUpdateAction.java b/designer-base/src/main/java/com/fr/design/update/actions/SoftwareUpdateAction.java index cb412dcb1f..d65d8fec58 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/SoftwareUpdateAction.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/SoftwareUpdateAction.java @@ -2,8 +2,9 @@ package com.fr.design.update.actions; import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.update.ui.dialog.UpdateMainDialog; +import com.fr.design.os.impl.UpdateDialogAction; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; import java.awt.event.ActionEvent; @@ -12,7 +13,6 @@ import java.awt.event.ActionEvent; */ public class SoftwareUpdateAction extends UpdateAction { - public SoftwareUpdateAction() { setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_UpdateAndUpgrade")); setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/update/update_new.png")); @@ -26,8 +26,9 @@ public class SoftwareUpdateAction extends UpdateAction { */ @Override public void actionPerformed(ActionEvent e) { - UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); - dialog.showDialog(); + //说之后更新升级要用jxbrowser,Linux下进平台 + OSBasedAction osBasedAction = OSSupportCenter.getAction(UpdateDialogAction.class); + osBasedAction.execute(); } } diff --git a/designer-base/src/main/java/com/fr/design/update/domain/UpdateConstants.java b/designer-base/src/main/java/com/fr/design/update/domain/UpdateConstants.java deleted file mode 100644 index 737deafe6e..0000000000 --- a/designer-base/src/main/java/com/fr/design/update/domain/UpdateConstants.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.fr.design.update.domain; - -/** - * Created by XINZAI on 2018/8/21. - */ - - -import java.awt.Color; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * 更新升级的常量 - */ -public interface UpdateConstants { - - String APPS_FOLDER_NAME = "webapps"; - - int CONNECTION_TIMEOUT = 1000 * 5; - Color BAR_COLOR = new Color(0x3384F0); - - String CHANGELOG_X_START = "2018-07-11"; - - String DEFAULT_APP_NAME = "FineReport"; - String DOWNLOAD_DIR = "update"; - String DESIGNER_BACKUP_DIR = "designerbackup"; - - String UPDATE_CACHE_CONFIG_X = "updateCacheConfig10"; - String UPDATE_CACHE_INFO_X = "updateCacheInfo10"; - - - int BYTE = 153600; - - List JARS_FOR_SERVER_X = Collections.unmodifiableList(Arrays.asList(new String[]{ - "fine-activator-10.0.jar", - "fine-core-10.0.jar", - "fine-report-engine-10.0.jar", - "fine-decision-10.0.jar", - "fine-decision-report-10.0.jar", - "fine-schedule-10.0.jar", - "fine-schedule-report-10.0.jar", - "fine-swift-log-adaptor-10.0.jar", - "fine-webui-10.0.jar", - "fine-datasource-10.0.jar", - "fine-third-10.0.jar", - "fine-accumulator-10.0.jar" - })); - - List JARS_FOR_DESIGNER_X = Collections.unmodifiableList(Arrays.asList(new String[]{ - "fine-report-designer-10.0.jar", - "aspectjrt.jar" - })); - - - List LOG_TYPE = Collections.unmodifiableList(Arrays.asList(new String[]{ - "REPORT", "MOBILE", "CHART", "PFC", "BI" - })); - -} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java index 44cfb146b1..dcc282c53f 100644 --- a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java +++ b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java @@ -4,6 +4,7 @@ import com.fr.concurrent.NamedThreadFactory; import com.fr.design.event.DesignerOpenedListener; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.general.CloudCenter; import com.fr.general.GeneralContext; @@ -12,6 +13,9 @@ import com.fr.general.http.HttpToolbox; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; import com.fr.workspace.WorkContext; import java.util.concurrent.ExecutorService; @@ -81,21 +85,6 @@ public class DesignerPushUpdateManager { return StringUtils.EMPTY; } - /** - * "自动更新推送"选项是否生效 - */ - public boolean isAutoPushUpdateSupported() { - boolean isLocalEnv = WorkContext.getCurrent().isLocal(); - boolean isChineseEnv = GeneralContext.isChineseEnv(); - - return isAutoPushUpdateSupported(isLocalEnv, isChineseEnv); - } - - private boolean isAutoPushUpdateSupported(boolean isLocalEnv, boolean isChineseEnv) { - // 远程设计和非中文环境,都不生效 - return isLocalEnv && isChineseEnv; - } - /** * 检查更新,如果有合适的更新版本,则弹窗 */ @@ -129,8 +118,7 @@ public class DesignerPushUpdateManager { initUpdateInfo(currentVersion, latestVersion); } } - - return isAutoPushUpdateSupported() && updateInfo.hasNewPushVersion(); + return SupportOSImpl.AUTOPUSHUPDATE.support() && updateInfo.hasNewPushVersion(); } private boolean isValidJarVersion(String fullCurrentVersion, String fullLatestVersion) { diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java index 402df06b8a..8ffe8d4a41 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java @@ -1,9 +1,9 @@ package com.fr.design.update.ui.dialog; +import com.fr.decision.update.data.UpdateConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.update.domain.UpdateConstants; import com.fr.design.update.factory.DirectoryOperationFactory; import com.fr.design.update.ui.widget.ColorfulCellRender; import com.fr.design.utils.gui.GUICoreUtils; 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 0e83ff12f1..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 @@ -1,18 +1,16 @@ package com.fr.design.update.ui.dialog; +import com.fr.decision.update.data.UpdateConstants; import com.fr.design.RestartHelper; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.update.domain.UpdateConstants; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; -import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; - import javax.swing.AbstractAction; import javax.swing.BorderFactory; import javax.swing.JDialog; @@ -25,6 +23,7 @@ import java.awt.Font; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -45,7 +44,7 @@ public class RestoreResultDialog extends JDialog { initCommonComponents(); } - public RestoreResultDialog(Frame parent, boolean modal, String jarDir) { + RestoreResultDialog(Frame parent, boolean modal, String jarDir) { super(parent, modal); this.jarRestoreDir = jarDir; if (ComparatorUtils.equals(jarDir, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Restore_Old_Version"))) { @@ -92,9 +91,7 @@ public class RestoreResultDialog extends JDialog { jarProgressLabel.setVisible(true); progressLabelPane.add(jarProgressLabel); pane.add(progressLabelPane, BorderLayout.CENTER); - - UpdateMainDialog.deletePreviousPropertyFile(); - + deletePreviousPropertyFile(); putJarBackupFiles(); restartButton.setEnabled(true); restartLaterButton.setEnabled(true); @@ -102,6 +99,15 @@ public class RestoreResultDialog extends JDialog { this.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Jar_Restore")); } + static boolean deletePreviousPropertyFile() { + File moveFile = new File(RestartHelper.MOVE_FILE); + File delFile = new File(RestartHelper.RECORD_FILE); + if (StableUtils.mkdirs(moveFile) && StableUtils.mkdirs(delFile)) { + return StableUtils.deleteFile(moveFile) && StableUtils.deleteFile(delFile); + } + return false; + } + private void initOldVersionRestoreComps() { this.setResizable(false); JPanel pane = new JPanel(); @@ -136,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")); } @@ -151,33 +156,73 @@ public class RestoreResultDialog extends JDialog { } private void putJarBackupFiles() { - Map map = new HashMap(); - java.util.List list = new ArrayList(); + Map map = new HashMap<>(); + 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, java.util.List list) { - List files = UpdateConstants.JARS_FOR_DESIGNER_X; + private void filesToMove(String installHome, Map map) { String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR; - for (String file : files) { - map.put(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, file), - StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file)); - list.add(StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file)); + 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 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, java.util.List list) { - List files = UpdateConstants.JARS_FOR_SERVER_X; - String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR; - for (String file : files) { - map.put(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, file), - StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)); - list.add(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)); + 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) { + 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())); + } + } } } } \ No newline at end of file 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 9e83e40ddb..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 @@ -1,5 +1,6 @@ package com.fr.design.update.ui.dialog; +import com.fr.decision.update.data.UpdateConstants; import com.fr.decision.update.info.UpdateCallBack; import com.fr.decision.update.info.UpdateProgressCallBack; import com.fr.design.RestartHelper; @@ -9,11 +10,11 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.update.actions.FileProcess; -import com.fr.design.update.domain.UpdateConstants; import com.fr.design.update.domain.UpdateInfoCachePropertyManager; import com.fr.design.update.factory.DirectoryOperationFactory; import com.fr.design.update.ui.widget.LoadingLabel; @@ -23,22 +24,16 @@ import com.fr.design.update.ui.widget.UpdateInfoTableCellRender; import com.fr.design.update.ui.widget.UpdateInfoTableModel; import com.fr.design.update.ui.widget.UpdateInfoTextAreaCellRender; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.CloudCenter; -import com.fr.general.ComparatorUtils; -import com.fr.general.DateUtils; -import com.fr.general.GeneralContext; -import com.fr.general.GeneralUtils; -import com.fr.general.SiteCenter; -import com.fr.general.http.HttpClient; +import com.fr.general.*; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; -import com.fr.stable.ArrayUtils; -import com.fr.stable.EncodeConstants; -import com.fr.stable.ProductConstants; -import com.fr.stable.StableUtils; -import com.fr.stable.StringUtils; +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; import com.fr.workspace.WorkContext; import com.sun.java.swing.plaf.motif.MotifProgressBarUI; @@ -46,29 +41,20 @@ import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.table.TableRowSorter; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dialog; -import java.awt.Dimension; -import java.awt.Frame; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; +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.*; +import static javax.swing.JOptionPane.QUESTION_MESSAGE; + /** * Created by XINZAI on 2018/8/21. */ @@ -121,8 +107,6 @@ public class UpdateMainDialog extends UIDialog { //搜索更新信息关键词文本框 private UITextField searchUpdateInfoKeyword; - private boolean updateSuccessful; - private UpdateInfoTable updateInfoTable; private ArrayList updateInfoList; @@ -248,12 +232,12 @@ public class UpdateMainDialog extends UIDialog { updateInfoTable.setShowGrid(false); updateInfoTable.setCellSelectionEnabled(false); - TableRowSorter sorter = new TableRowSorter(updateInfoTable.getDataModel()); + TableRowSorter sorter = new TableRowSorter<>(updateInfoTable.getDataModel()); sorter.setSortable(updateTimeColIndex, true); sorter.setSortable(updateTitleColIndex, false); sorter.setSortable(updateSignColIndex, false); updateInfoTable.setRowSorter(sorter); - List sortKeys = new ArrayList(); + List sortKeys = new ArrayList<>(); sortKeys.add(new RowSorter.SortKey(updateTimeColIndex, SortOrder.DESCENDING)); sorter.setSortKeys(sortKeys); @@ -367,6 +351,7 @@ public class UpdateMainDialog extends UIDialog { try { downloadFileConfig = get(); showDownLoadInfo(); + afterInit(); } catch (InterruptedException e) { stopLoading(); Thread.currentThread().interrupt(); @@ -380,7 +365,7 @@ public class UpdateMainDialog extends UIDialog { } private SwingWorker getUpdateInfo(final String keyword) { - updateInfoList = new ArrayList(); + updateInfoList = new ArrayList<>(); lastUpdateCacheTime = UpdateConstants.CHANGELOG_X_START; String cacheConfigPath = getUpdateCacheConfig(); cacheProperty = new UpdateInfoCachePropertyManager(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), "resources", "offlineres", cacheConfigPath)); @@ -395,6 +380,8 @@ public class UpdateMainDialog extends UIDialog { return new SwingWorker() { @Override protected JSONArray doInBackground() { + CloseableHttpClient httpClient; + CloseableHttpResponse response; try { getUpdateInfoSuccess = false; //step1:read from cache file @@ -403,16 +390,15 @@ public class UpdateMainDialog extends UIDialog { if (downloadFileConfig == null) { throw new Exception("network error."); } - HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("changelog10") + "&start=" + lastUpdateCacheTime + "&end=" + getLatestJARTimeStr()); - hc.asGet(); - hc.setTimeout(UpdateConstants.CONNECTION_TIMEOUT * 2); - String responseText = hc.getResponseText(); + HttpGet get = new HttpGet(CloudCenter.getInstance().acquireUrlByKind("changelog10") + "&start=" + lastUpdateCacheTime + "&end=" + getLatestJARTimeStr()); + httpClient = HttpToolbox.getHttpClient(CloudCenter.getInstance().acquireUrlByKind("changelog10") + "&start=" + lastUpdateCacheTime + "&end=" + getLatestJARTimeStr()); + response = httpClient.execute(get); + String responseText = CommonIOUtils.inputStream2String(response.getEntity().getContent(),EncodeConstants.ENCODING_UTF_8).trim(); JSONArray array = JSONArray.create(); //假如返回"-1",说明socket出错了 if (!ComparatorUtils.equals(responseText, "-1")) { array = new JSONArray(responseText); } - hc.release(); return array; } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage()); @@ -430,7 +416,6 @@ public class UpdateMainDialog extends UIDialog { getUpdateInfoSuccess = true; //step4:update cache file,start from cacheRecordTime,end latest server jartime updateCachedInfoFile(jsonArray); - afterInit(); } catch (Exception e) { getUpdateInfoSuccess = true; FineLoggerFactory.getLogger().error(e.getMessage()); @@ -441,6 +426,7 @@ public class UpdateMainDialog extends UIDialog { private void afterInit() { if (autoUpdateAfterInit) { + updateButton.setEnabled(true); updateButton.doClick(); } } @@ -454,7 +440,7 @@ public class UpdateMainDialog extends UIDialog { return; } if (cacheFile.exists()) { - try (InputStreamReader streamReader = new InputStreamReader(new FileInputStream(cacheFile), "UTF-8"); + try (InputStreamReader streamReader = new InputStreamReader(new FileInputStream(cacheFile), StandardCharsets.UTF_8); BufferedReader br = new BufferedReader(streamReader)) { String readStr, updateTimeStr; while ((readStr = br.readLine()) != null) { @@ -499,13 +485,14 @@ public class UpdateMainDialog extends UIDialog { if (endTime.equals(lastUpdateCacheTime) || jsonArray.length() == 0 || ComparatorUtils.compare(endTime, lastUpdateCacheTime) <= 0) { return; } - try (OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(cacheFile), EncodeConstants.ENCODING_UTF_8); - BufferedWriter bufferWriter = new BufferedWriter(writerStream)) { - for (int i = 0; i < jsonArray.length(); i++) { - JSONObject jo = (JSONObject) jsonArray.get(i); - bufferWriter.write((String) jo.get("update") + '\t' + jo.get("title")); - bufferWriter.newLine(); - bufferWriter.flush(); + try (OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(cacheFile), UTF_8)) { + try (BufferedWriter bufferWriter = new BufferedWriter(writerStream)) { + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject jo = (JSONObject) jsonArray.get(i); + bufferWriter.write((String) jo.get("update") + '\t' + jo.get("title")); + bufferWriter.newLine(); + bufferWriter.flush(); + } } } lastUpdateCacheState = UPDATE_CACHE_STATE_SUCCESS; @@ -523,6 +510,9 @@ public class UpdateMainDialog extends UIDialog { //形如 Build#release-2018.07.31.03.03.52.80 String currentNO = GeneralUtils.readBuildNO(); Date curJarDate = UPDATE_INFO_TABLE_FORMAT.parse(currentNO, new ParsePosition(currentNO.indexOf("-") + 1)); + if (curJarDate == null) { + curJarDate = updateTime; + } if (!ComparatorUtils.equals(keyword, StringUtils.EMPTY)) { if (!containsKeyword(UPDATE_INFO_TABLE_FORMAT.format(updateTime), keyword) && !containsKeyword(updateTitle, keyword)) { continue; @@ -532,7 +522,7 @@ public class UpdateMainDialog extends UIDialog { updateInfoList.add(new Object[]{UPDATE_INFO_TABLE_FORMAT.format(updateTime), updateTitle, updateTime.after(curJarDate)}); } } - return new ArrayList(updateInfoList); + return new ArrayList<>(updateInfoList); } private boolean containsKeyword(String str, String keyword) { @@ -594,25 +584,32 @@ public class UpdateMainDialog extends UIDialog { updateButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - if (updateSuccessful) { - RestartHelper.restart(); - } else { + String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")}; + int a = JOptionPane.showOptionDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Information"), + Toolkit.i18nText("Fine-Design_Update_Info_Title"),JOptionPane.YES_NO_OPTION, QUESTION_MESSAGE, UIManager.getIcon("OptionPane.warningIcon"), option, 1); + if (a == 0) { progressBar.setVisible(true); + progressBar.setString(Toolkit.i18nText("Fine-Design_Update_Info_Wait_Message")); UpdateCallBack callBack = new UpdateProgressCallBack(progressBar); - deletePreviousPropertyFile(); 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() { - updateButton.setEnabled(true); progressBar.setVisible(false); - updateSuccessful = true; - updateButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Restart_Designer")); + deleteForDesignerUpdate(installLib); + helper.restartForUpdate(frame); } @Override public void onDownloadFailed() { progressBar.setVisible(false); + deleteForDesignerUpdate(installLib); + JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); + helper.restartForUpdate(frame); } }.execute(); } @@ -620,22 +617,11 @@ public class UpdateMainDialog extends UIDialog { }); } - /** - * 确保升级更新之前删除以前的配置文件 - */ - public static void deletePreviousPropertyFile() { - //在进行更新升级之前确保move和delete.properties删除 - File moveFile = new File(RestartHelper.MOVE_FILE); - File delFile = new File(RestartHelper.RECORD_FILE); - if ((moveFile.exists()) && (!moveFile.delete())) { - FineLoggerFactory.getLogger().error(RestartHelper.MOVE_FILE + "delete failed!"); - } - if ((delFile.exists()) && (!delFile.delete())) { - FineLoggerFactory.getLogger().error(RestartHelper.RECORD_FILE + "delete failed!"); - } + private void deleteForDesignerUpdate(String installLib) { + File dir = new File(installLib); + CommonUtils.deleteFile(dir); } - //获取备份目录 private String getBackupDirectory() { return UpdateConstants.DESIGNER_BACKUP_DIR; @@ -687,10 +673,8 @@ public class UpdateMainDialog extends UIDialog { /** * 检查有效性 * - * @throws Exception */ @Override public void checkValid() throws Exception { - } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java index 5b90d43307..5238b0c657 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java @@ -1,11 +1,15 @@ package com.fr.design.upm; import com.fr.base.FRContext; +import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader; import com.fr.design.dialog.UIDialog; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; +import com.fr.log.FineLoggerFactory; import com.fr.stable.StableUtils; import com.fr.workspace.Workspace; import com.fr.workspace.WorkspaceEvent; @@ -51,11 +55,43 @@ public class UpmFinder { } public static void showUPMDialog() { - UpmShowPane upmPane = new UpmShowPane(); - if (dialog == null) { - dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane); + boolean flag = true; + try { + Class.forName("com.teamdev.jxbrowser.chromium.Browser"); + } catch (ClassNotFoundException e) { + flag = false; + } + if (flag) { + if (!checkUPMResourcesExist()){ + // upm下载 + int val = JOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Install"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); + if (val == JOptionPane.OK_OPTION){ + try { + UpmResourceLoader.INSTANCE.download(); + UpmResourceLoader.INSTANCE.install(); + JOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE); + } catch (Exception e){ + FineLoggerFactory.getLogger().error(e.getMessage(), e); + JOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Updater_Download_Failed"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE); + } + } + } + else { + UpmShowPane upmPane = new UpmShowPane(); + if (dialog == null) { + dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane); + } + dialog.setVisible(true); + } + } else { + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message")); + UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); + dialog.setAutoUpdateAfterInit(); + dialog.showDialog(); } - dialog.setVisible(true); } public static void closeWindow() { diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmShowDialog.java b/designer-base/src/main/java/com/fr/design/upm/UpmShowDialog.java index 704e011218..d5f132e98f 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmShowDialog.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmShowDialog.java @@ -3,7 +3,6 @@ package com.fr.design.upm; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.UIDialog; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.stable.StableUtils; import javax.swing.*; import java.awt.*; @@ -30,5 +29,6 @@ public class UpmShowDialog extends UIDialog { @Override public void checkValid() throws Exception { + } } diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java b/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java index 57b225920a..1bc4b9e948 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java @@ -27,43 +27,43 @@ public class UpmShowPane extends BasicPane { return "UPM"; } - public UpmShowPane() { + UpmShowPane() { setLayout(new BorderLayout()); - if (UpmFinder.checkUPMResourcesExist()) { - modernUIPane = new ModernUIPane.Builder<>() - .prepare(new ScriptContextAdapter() { - @Override - public void onScriptContextCreated(ScriptContextEvent event) { - JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); - window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser())); - } - }) - .withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()) - .build(); - EventDispatcher.listen(DownloadEvent.UPDATE, new Listener() { - @Override - public void on(Event event, String param) { - modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); - } - }); - } else { - modernUIPane = new ModernUIPane.Builder<>() - .withComponent(WarnComponent.KEY) - .prepare(new ScriptContextAdapter() { - @Override - public void onScriptContextCreated(ScriptContextEvent event) { - JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); - window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser())); - } - }).build(); - EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener() { - @Override - public void on(Event event, String param) { - modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); - } - }); - } +// 先屏蔽掉这个判断,后续可能修改交互 +// if (UpmFinder.checkUPMResourcesExist()) { + modernUIPane = new ModernUIPane.Builder<>() + .prepare(new ScriptContextAdapter() { + @Override + public void onScriptContextCreated(ScriptContextEvent event) { + JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); + window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser())); + } + }) + .withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()) + .build(); + EventDispatcher.listen(DownloadEvent.UPDATE, new Listener() { + @Override + public void on(Event event, String param) { + modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); + } + }); +// } else { +// modernUIPane = new ModernUIPane.Builder<>() +// .withComponent(WarnComponent.KEY) +// .prepare(new ScriptContextAdapter() { +// @Override +// public void onScriptContextCreated(ScriptContextEvent event) { +// JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); +// window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser())); +// } +// }).build(); +// EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener() { +// @Override +// public void on(Event event, String param) { +// modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); +// } +// }); +// } add(modernUIPane, BorderLayout.CENTER); } - } diff --git a/designer-base/src/main/java/com/fr/design/utils/ImageUtils.java b/designer-base/src/main/java/com/fr/design/utils/ImageUtils.java index 389b9981e9..7bd2d406ec 100644 --- a/designer-base/src/main/java/com/fr/design/utils/ImageUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/ImageUtils.java @@ -240,6 +240,7 @@ public class ImageUtils { * @param opacityCompatible 是否处理背景透明 */ public static BufferedImage scale(BufferedImage srcImg, float scale, boolean opacityCompatible) { + int scaleType; if (scale < 0) { // 自动修正负数 scale = -scale; @@ -247,7 +248,15 @@ public class ImageUtils { int width = mul(Integer.toString(srcImg.getWidth(null)), Float.toString(scale)).intValue(); // 得到源图宽 int height = mul(Integer.toString(srcImg.getHeight(null)), Float.toString(scale)).intValue(); // 得到源图长 - return CoreGraphHelper.toBufferedImage(scale(srcImg, width, height, opacityCompatible)); + int srcHeight = srcImg.getHeight(null); + int srcWidth = srcImg.getWidth(null); + if (srcHeight < height || srcWidth < width) { + // 放大图片使用平滑模式 + scaleType = Image.SCALE_SMOOTH; + } else { + scaleType = Image.SCALE_DEFAULT; + } + return CoreGraphHelper.toBufferedImage(scale(srcImg, width, height, opacityCompatible, scaleType)); } private static BigDecimal mul(String v1, String v2) { @@ -268,18 +277,12 @@ public class ImageUtils { * @param opacityCompatible 是否处理背景透明 * @return {@link Image} */ - private static Image scale(BufferedImage srcImg, int width, int height, boolean opacityCompatible) { + public static Image scale(BufferedImage srcImg, int width, int height, boolean opacityCompatible, int scaleType) { int srcHeight = srcImg.getHeight(null); int srcWidth = srcImg.getWidth(null); - int scaleType; if (srcHeight == height && srcWidth == width) { // 源与目标长宽一致返回原图 return srcImg; - } else if (srcHeight < height || srcWidth < width) { - // 放大图片使用平滑模式 - scaleType = Image.SCALE_SMOOTH; - } else { - scaleType = Image.SCALE_DEFAULT; } if (opacityCompatible) {//需要保留透明度背景 BufferedImage toImg = CoreGraphHelper.createBufferedImage(width, height, srcImg.getType()); 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/design/web/CustomIconPane.java b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java index 0231963b9c..e4aedd4219 100644 --- a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java +++ b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java @@ -16,12 +16,12 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.utils.ImageUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.form.ui.WidgetInfoConfig; import com.fr.general.ComparatorUtils; import com.fr.stable.Constants; -import com.fr.stable.CoreGraphHelper; import com.fr.stable.ListMap; import com.fr.stable.StringUtils; import com.fr.transaction.Configurations; @@ -39,6 +39,9 @@ import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; /** * carl:自定义Icon编辑 @@ -452,13 +455,7 @@ public class CustomIconPane extends BasicPane { String path = jf.getSelectedFile().getAbsolutePath(); // 图片存储有最大值48*48限制,没有超过最大值时,按原图大小存储,超过最大值后,压缩至最大值存储 Image image = BaseUtils.readImage(path); - BufferedImage bufferedImage = CoreGraphHelper.createBufferedImage(Math.min(image.getWidth(null), IconManager.MAXSTORAGE_ICONWIDTH), - Math.min(image.getHeight(null), IconManager.MAXSTORAGE_ICONHEIGHT), BufferedImage.TYPE_INT_ARGB); - Graphics2D g2d = bufferedImage.createGraphics(); - g2d.drawImage(image, 0, 0, Math.min(image.getWidth(null), IconManager.MAXSTORAGE_ICONWIDTH), Math.min(image.getHeight(null), IconManager.MAXSTORAGE_ICONHEIGHT), null); - bufferedImage.flush(); - g2d.dispose(); - iconImage = bufferedImage; + iconImage = ImageUtils.scale((BufferedImage) image, Math.min(image.getWidth(null), IconManager.MAXSTORAGE_ICONWIDTH), Math.min(image.getHeight(null), IconManager.MAXSTORAGE_ICONHEIGHT), true, Image.SCALE_SMOOTH); if (iconImage != null) { showImageLabel.setIcon(new ImageIcon(iconImage)); } 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/main/java/com/fr/file/FileNodeFILE.java b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java index dce2c38e0b..138cfe3456 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java @@ -23,7 +23,7 @@ import com.fr.workspace.WorkspaceEvent; import com.fr.workspace.resource.WorkResourceTempRenameStream; import com.fr.workspace.server.lock.TplOperator; -import javax.swing.Icon; +import javax.swing.*; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.OutputStream; @@ -68,14 +68,14 @@ public class FileNodeFILE implements FILE { this.node = new FileNode(StableUtils.pathJoin(parentDir, name), isDir); this.envPath = WorkContext.getCurrent().getPath(); - this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node); + this.hasFullAuth = NodeAuthProcessor.getInstance().checkFileNodeAuth(node); } public FileNodeFILE(FileNode node) { this.node = node; this.envPath = WorkContext.getCurrent().getPath(); - this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node); + this.hasFullAuth = NodeAuthProcessor.getInstance().checkFileNodeAuth(node); } public FileNodeFILE(FileNode node, boolean hasFullAuth) { @@ -91,7 +91,7 @@ public class FileNodeFILE implements FILE { public FileNodeFILE(FileNode node, String envPath) { this.node = node; this.envPath = envPath; - this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node); + this.hasFullAuth = NodeAuthProcessor.getInstance().checkFileNodeAuth(node); } public FileNodeFILE(FileNode node, String envPath, boolean hasFullAuth) { diff --git a/designer-base/src/main/java/com/fr/start/Demo.java b/designer-base/src/main/java/com/fr/start/Demo.java index bac5a9b0f0..58f4050fd0 100644 --- a/designer-base/src/main/java/com/fr/start/Demo.java +++ b/designer-base/src/main/java/com/fr/start/Demo.java @@ -1,46 +1,13 @@ package com.fr.start; - -import com.fr.log.FineLoggerFactory; -import com.fr.stable.OperatingSystem; -import com.fr.stable.StableUtils; - -import java.io.IOException; +import com.fr.design.os.impl.DemoAction; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; public class Demo { public static void main(String[] args) { - String installHome = StableUtils.getInstallHome(); - if (installHome == null) { - FineLoggerFactory.getLogger().error("Can not find the install home, please check it."); - return; - } - - String executorPath; - - if (OperatingSystem.isMacOS()) { - executorPath = StableUtils.pathJoin(installHome, "bin", "designer.app"); - } else { - executorPath = StableUtils.pathJoin(installHome, "bin", "designer.exe demo"); - } - - if (OperatingSystem.isMacOS()) { - ProcessBuilder builder = new ProcessBuilder(); - builder.command("open", "-a", executorPath, "--args", "demo"); - try { - builder.start(); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } else { - // ProcessBuilder这种方式在window下报错:系统找不到指定文件 - Runtime rt = Runtime.getRuntime(); - try { - rt.exec(executorPath); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - + OSBasedAction osBasedAction = OSSupportCenter.getAction(DemoAction.class); + osBasedAction.execute(); System.exit(0); } } \ No newline at end of file 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/design/update/ui/dialog/RestoreResultDialogTest.java b/designer-base/src/test/java/com/fr/design/update/ui/dialog/RestoreResultDialogTest.java new file mode 100644 index 0000000000..86be0450e7 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/update/ui/dialog/RestoreResultDialogTest.java @@ -0,0 +1,26 @@ +package com.fr.design.update.ui.dialog; + +import com.fr.design.RestartHelper; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StableUtils; +import org.junit.Assert; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; + +public class RestoreResultDialogTest { + + @Test + public void testDeletePreviousPropertyFile() { + File moveFile = new File(RestartHelper.MOVE_FILE); + File recordFile = new File(RestartHelper.RECORD_FILE); + try { + StableUtils.makesureFileExist(moveFile); + StableUtils.makesureFileExist(recordFile); + Assert.assertTrue(RestoreResultDialog.deletePreviousPropertyFile()); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(),e); + } + } +} 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/ChartTypeInterfaceManager.java b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java index b9950256f3..317d17bdb0 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -11,6 +11,18 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.chart.fun.ChartTypeUIProvider; import com.fr.design.chart.gui.ChartWidgetOption; +import com.fr.design.condition.ConditionAttributesPane; +import com.fr.design.gui.core.WidgetOption; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.mainframe.chart.AbstractChartAttrPane; +import com.fr.design.mainframe.chart.ChartEditPane; +import com.fr.design.mainframe.chart.ChartsConfigPane; +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.design.module.DesignModuleFactory; import com.fr.design.type.ui.AreaChartTypeUI; import com.fr.design.type.ui.BarChartTypeUI; import com.fr.design.type.ui.BubbleChartTypeUI; @@ -28,18 +40,6 @@ import com.fr.design.type.ui.RadarChartTypeUI; import com.fr.design.type.ui.RangeChartTypeUI; import com.fr.design.type.ui.StockChartTypeUI; import com.fr.design.type.ui.XYScatterChartTypeUI; -import com.fr.design.condition.ConditionAttributesPane; -import com.fr.design.gui.core.WidgetOption; -import com.fr.design.gui.frpane.AttributeChangeListener; -import com.fr.design.mainframe.chart.AbstractChartAttrPane; -import com.fr.design.mainframe.chart.ChartEditPane; -import com.fr.design.mainframe.chart.ChartsConfigPane; -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.design.module.DesignModuleFactory; import com.fr.extended.chart.AbstractChart; import com.fr.form.ui.ChartEditor; import com.fr.general.GeneralContext; @@ -80,7 +80,7 @@ import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.van.chart.area.AreaIndependentVanChartInterface; import com.fr.van.chart.bar.BarIndependentVanChartInterface; import com.fr.van.chart.bubble.BubbleIndependentVanChartInterface; -import com.fr.van.chart.column.ColumnIndependentVanChartInterface; +import com.fr.van.chart.column.VanColumnChartTypeUI; import com.fr.van.chart.custom.CustomIndependentVanChartInterface; import com.fr.van.chart.drillmap.DrillMapIndependentVanChartInterface; import com.fr.van.chart.funnel.designer.FunnelIndependentVanChartInterface; @@ -93,7 +93,7 @@ import com.fr.van.chart.multilayer.MultiPieIndependentVanChartInterface; import com.fr.van.chart.pie.PieIndependentVanChartInterface; import com.fr.van.chart.radar.RadarIndependentVanChartInterface; import com.fr.van.chart.scatter.ScatterIndependentVanChartInterface; -import com.fr.van.chart.structure.desinger.StructureIndependentVanChartInterface; +import com.fr.van.chart.structure.desinger.VanStructureChartTypeUI; import com.fr.van.chart.treemap.TreeMapIndependentVanChartInterface; import com.fr.van.chart.wordcloud.designer.WordCloudIndependentVanChartInterface; @@ -165,7 +165,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr ChartWidgetOption[] child = new ChartWidgetOption[chartIDs.length]; int index = 0; for (String chartID : chartIDs) { - ChartProvider[] rowChart = ChartTypeManager.getInstance().getChartTypes(chartID); + ChartProvider[] rowChart = ChartTypeManager.getInstance().getCharts(chartID); if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(chartID)) { continue; } @@ -182,7 +182,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr private static void readVanChart() { addChartTypeInterface(VAN_CHART_PRIORITY, PiePlot4VanChart.VAN_CHART_PIE_PLOT, new PieIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID, new ColumnIndependentVanChartInterface()); + addChartTypeInterface(VAN_CHART_PRIORITY, VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID, new VanColumnChartTypeUI()); addChartTypeInterface(VAN_CHART_PRIORITY, VanChartColumnPlot.VAN_CHART_BAR_PLOT_ID, new BarIndependentVanChartInterface()); addChartTypeInterface(VAN_CHART_PRIORITY, VanChartLinePlot.VAN_CHART_LINE_PLOT, new LineIndependentVanChartInterface()); addChartTypeInterface(VAN_CHART_PRIORITY, VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID, new AreaIndependentVanChartInterface()); @@ -199,7 +199,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr addChartTypeInterface(VAN_CHART_PRIORITY, VanChartHeatMapPlot.VAN_CHART_HEAT_MAP_ID, new HeatMapIndependentVanChartInterface()); addChartTypeInterface(VAN_CHART_PRIORITY, VanChartWordCloudPlot.WORD_CLOUD_PLOT_ID, new WordCloudIndependentVanChartInterface()); addChartTypeInterface(VAN_CHART_PRIORITY, VanChartGanttPlot.VAN_CHART_GANTT_PLOT_ID, new GanttIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartStructurePlot.STRUCTURE_PLOT_ID, new StructureIndependentVanChartInterface()); + addChartTypeInterface(VAN_CHART_PRIORITY, VanChartStructurePlot.STRUCTURE_PLOT_ID, new VanStructureChartTypeUI()); } @@ -364,7 +364,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr try { //兼容 图表类型选择界面会调到这边 - ChartProvider[] charts = ChartTypeManager.getInstanceWithCheck().getChartTypes(chartID); + ChartProvider[] charts = ChartTypeManager.getInstanceWithCheck().getCharts(chartID); result = new String[charts.length]; for (int i = 0; i < charts.length; i++) { //Chart && AbstractChart @@ -403,7 +403,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr //兼容 private String[] getCompatibleSubName(String chartID, ChartTypeUIProvider provider) { - ChartProvider[] chartProviders = ChartTypeManager.getInstanceWithCheck().getChartTypes(chartID); + ChartProvider[] chartProviders = ChartTypeManager.getInstanceWithCheck().getCharts(chartID); if (chartProviders.length == 1) { return new String[]{getName(chartID)}; @@ -453,7 +453,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr try { - ChartProvider chartProvider = ChartTypeManager.getInstanceWithCheck().getChartTypes(chartID)[0]; + ChartProvider chartProvider = ChartTypeManager.getInstanceWithCheck().getCharts(chartID)[0]; if (chartProvider instanceof Chart) { //AbstractExtendedChartUIProvider result = ((Chart) chartProvider).getChartName(); 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/ChartIcon.java b/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java index 7485d57973..854505d630 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java @@ -44,6 +44,7 @@ public class ChartIcon implements Icon, XMLable { * @param x 缩略图的起始坐标x * @param y 缩略图的起始坐标y */ + @Override public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2d = (Graphics2D) g; @@ -66,6 +67,7 @@ public class ChartIcon implements Icon, XMLable { * * @return int 缩略图宽度 */ + @Override public int getIconWidth() { return WIDTH; } @@ -75,6 +77,7 @@ public class ChartIcon implements Icon, XMLable { * * @return int 缩略图高度 */ + @Override public int getIconHeight() { return HEIGHT; } @@ -94,18 +97,21 @@ public class ChartIcon implements Icon, XMLable { } + @Override public void readXML(XMLableReader reader) { - + //do nothing } + @Override public void writeXML(XMLPrintWriter writer) { - + //do nothing } /** * @return 克隆后的对象 * @throws CloneNotSupportedException 如果克隆失败则抛出此异常 */ + @Override public Object clone() throws CloneNotSupportedException { ChartIcon cloned = (ChartIcon) super.clone(); cloned.imagePath = this.imagePath; 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 0eb70fd129..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,10 +123,10 @@ 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().getChartTypes(plotID)[iconViewList.getSelectedIndex()]; + ChartProvider chart = ChartTypeManager.getInstance().getCharts(plotID)[iconViewList.getSelectedIndex()]; try { chart4Update = (ChartProvider) chart.clone(); cc.addChart(chart4Update); 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..3fae88fe40 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 @@ -55,12 +55,12 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene this(); populate(cc); } - + public ChartComponent(BaseChartCollection cc) { this(); populate(cc); } - + public ChartComponent(ChartCollection cc, PropertyChangeListener l) { this(); populate(cc); @@ -72,6 +72,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene * 右键编辑 图表编辑层的监听事件, 在停止编辑时 响应整个编辑模板(form, sheet)的改变. * @param l 监听事件 */ + @Override public void addStopEditingListener(PropertyChangeListener l) { if (!listeners.contains(l)) { listeners.add(l); @@ -87,6 +88,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene /** * 停止编辑, 通知事情, 刷新画出新界面. */ + @Override public void reset() { fireStopEditing(); @@ -97,6 +99,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene repaint(); } + @Override public void populate(BaseChartCollection cc) { // kunsnat_bug: 5471 实现设置的即时预览 try {// clone 为了判断编辑前后的值. this.chartCollection4Design = (ChartCollection)cc; @@ -107,6 +110,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene reset(); } + @Override public BaseChartCollection update() { return this.chartCollection4Design; } @@ -180,53 +184,63 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene * @param event 鼠标事件 * 不设置鼠标点击跳转事件 */ + @Override public void mouseClicked(MouseEvent event) { + //do nothing } /** * 鼠标按压 * @param e 鼠标事件 */ + @Override public void mousePressed(MouseEvent e) { - - + //do nothing } /** * 鼠标松开 * @param e 鼠标事件 */ - public void mouseReleased(MouseEvent e) { + @Override + public void mouseReleased(MouseEvent e) { + //do nothing } /** * 鼠标进入 * @param e 鼠标事件 */ + @Override public void mouseEntered(MouseEvent e) { - + //do nothing } /** * 鼠标退出 * @param e 鼠标事件 */ + @Override public void mouseExited(MouseEvent e) { - + //do nothing } /** * 鼠标拖拽 * @param e 鼠标事件 */ - public void mouseDragged(MouseEvent e) { + @Override + public void mouseDragged(MouseEvent e) { + //do nothing } /** * 鼠标移动 * @param e 鼠标事件 */ + @Override public void mouseMoved(MouseEvent e) { + //do nothing } private boolean needRefreshChartGlyph() { @@ -236,7 +250,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 paneList; + private UITabGroup tabPane; + + private String[] nameArray; + + @Override + protected void initContentPane() { + if (customPlot == null) { + return; + } + cardLayout = new CardLayout(); + initPaneList(); + relayoutWhenListChange(); + } + + private void initPaneList() { + + paneList = new ArrayList<>(); + + List customPlotList = customPlot.getCustomPlotList(); + + for (int i = 0; i < customPlotList.size(); i++) { + //根据不同的plot创建不同的数据配置界面 + final VanChartPlot vanChartPlot = customPlotList.get(i); + paneList.add(new AbstractVanSingleDataPane(listener) { + @Override + protected SingleDataPane createSingleDataPane() { + return createSingleDataPaneByPlot(vanChartPlot); + } + }); + } + } + + private SingleDataPane createSingleDataPaneByPlot(VanChartPlot plot) { + CustomPlotType customType = CustomPlotFactory.getCustomType(plot); + switch (customType) { + case RING: + case SLOT: + case CUVETTE: + //todo 仪表板没写好 + return new SingleDataPane(new SingleCategoryDataSetFieldsPane(), new SingleCategoryCellDataFieldsPane()); + case SCATTER: + case BUBBLE: + return new SingleDataPane(new ScatterDataSetFieldsPane(), new ScatterCellDataFieldsPane()); + default: + return StringUtils.equals(CustomStyle.CUSTOM.toString(), plot.getCustomType()) ? + new SingleDataPane(new SingleCategoryDataSetFieldsPane(), new SingleCategoryCellDataFieldsPane()) : + new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane()); + } + } + + private void relayoutWhenListChange() { + centerPane = new JPanel(cardLayout) { + @Override + public Dimension getPreferredSize() { + return paneList.get(tabPane.getSelectedIndex()).getPreferredSize(); + } + }; + + //获取tab的标题 + initTabTitle(); + + tabPane = new VanChartCustomPlotUITabGroup(nameArray) { + @Override + public void tabChanged(int index) { + dealWithTabChanged(index); + } + }; + tabPane.setSelectedIndex(0); + tabPane.tabChanged(0); + initLayout(); + } + + private void initTabTitle() { + + if (customPlot == null) { + return; + } + + List customPlotList = customPlot.getCustomPlotList(); + nameArray = new String[Math.min(customPlotList.size(), paneList.size())]; + for (int i = 0; i < nameArray.length; i++) { + JPanel pane = paneList.get(i); + VanChartPlot vanChartPlot = customPlotList.get(i); + CustomPlotType plotType = CustomPlotFactory.getCustomType(vanChartPlot); + + nameArray[i] = CustomPlotFactory.getTitle(plotType); + centerPane.add(pane, nameArray[i]); + } + } + + protected void dealWithTabChanged(int index) { + cardLayout.show(centerPane, nameArray[index]); + } + + private void initLayout() { + JPanel tabPanel = new JPanel(new BorderLayout()); + tabPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, getBackground())); + tabPanel.add(tabPane, BorderLayout.CENTER); + this.setLayout(new BorderLayout(0, 6)); + this.add(tabPanel, BorderLayout.NORTH); + this.add(centerPane, BorderLayout.CENTER); + } + + @Override + public void populate(ChartCollection collection) { + if (collection == null) { + return; + } + VanChart chart = collection.getSelectedChart(VanChart.class); + if (chart == null) { + return; + } + customPlot = chart.getPlot(); + + this.removeAll(); + initContentPane(); + + CustomChartDataDefinition dataSetCollection = (CustomChartDataDefinition) chart.getChartDataDefinition(); + + if (dataSetCollection != null) { + Map customDefinitions = dataSetCollection.getCustomDefinitions(); + for (int i = 0; i < paneList.size(); i++) { + VanChartPlot vanChartPlot = customPlot.getCustomPlotList().get(i); + AbstractDataDefinition dataDefinition = customDefinitions.get(CustomPlotFactory.getCustomType(vanChartPlot)); + if (dataDefinition != null) { + paneList.get(i).populate(dataDefinition); + } + } + } + + this.initAllListeners(); + this.validate(); + } + + + @Override + public void update(ChartCollection collection) { + if (collection == null) { + return; + } + VanChart chart = collection.getSelectedChart(VanChart.class); + if (chart == null) { + return; + } + Map definitions = new HashMap<>(); + for (int i = 0; i < paneList.size(); i++) { + definitions.put(CustomPlotFactory.getCustomType(customPlot.getCustomPlotList().get(i)), paneList.get(i).update()); + } + CustomChartDataDefinition customDefinition = new CustomChartDataDefinition(); + customDefinition.setCustomDefinitions(definitions); + chart.setChartDataDefinition(customDefinition); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java index 2a8154d7bb..6474cad0b6 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java @@ -24,7 +24,6 @@ import java.util.List; * 一列组件 可增可删,通过JComponent后面的加减button增删。 */ public abstract class AbstractMultiComponentPane extends JPanel { - private static final int COM_W = 96; private static final int H = 20; private static final int ICON_W = 20; @@ -50,7 +49,7 @@ public abstract class AbstractMultiComponentPane extends J label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); firstFieldComponent = createFirstFieldComponent(); - firstFieldComponent.setPreferredSize(new Dimension(COM_W, H)); + firstFieldComponent.setPreferredSize(new Dimension(componentWidth(), H)); addButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); addButton.setPreferredSize(new Dimension(ICON_W, H)); @@ -64,7 +63,7 @@ public abstract class AbstractMultiComponentPane extends J }); final JPanel panel = new JPanel(); - panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); + panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 2)); panel.add(label); panel.add(firstFieldComponent); @@ -78,6 +77,10 @@ public abstract class AbstractMultiComponentPane extends J this.add(boxPane, BorderLayout.CENTER); } + protected int componentWidth() { + return 96; + } + private JPanel addComboBoxAndButtonToBox(T uiComboBox, UIButton uiButton) { final JPanel panel = new JPanel(); panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); @@ -93,7 +96,7 @@ public abstract class AbstractMultiComponentPane extends J private void addNewComboBox() { final T comboBox = createOtherFieldComponent(); - comboBox.setPreferredSize(new Dimension(COM_W, H)); + comboBox.setPreferredSize(new Dimension(componentWidth(), H)); UIButton delButton = new UIButton(IOUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); delButton.setPreferredSize(new Dimension(ICON_W, H)); @@ -123,7 +126,7 @@ public abstract class AbstractMultiComponentPane extends J } private boolean canAdd() { - return categoryComponentList.size() < 3; + return categoryComponentList.size() < 2; } public List componentList() { diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java index 7c494aac1e..487c6cf135 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java @@ -2,10 +2,12 @@ package com.fr.design.chartx.component; import com.fr.base.Utils; import com.fr.chartx.data.field.DataFilterProperties; -import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.mainframe.chart.gui.data.PresentComboBox; import com.fr.design.mainframe.chart.gui.style.AbstractChartTabPane; @@ -22,7 +24,7 @@ import java.awt.Dimension; /** * Created by shine on 2019/07/18. */ -public abstract class AbstractSingleFilterPane extends AbstractChartTabPane { +public abstract class AbstractSingleFilterPane extends AbstractChartTabPane implements UIObserver { private static final int FIL_HEIGHT = 150; @@ -34,14 +36,12 @@ public abstract class AbstractSingleFilterPane extends AbstractChartTabPane categoryList = fieldCollection.getCategoryList(); + if (!categoryList.isEmpty()) { + populateCategory(categoryList.get(0).getFilterProperties()); + } + } + + public void updateMultiCategoryFieldCollection(MultiCategoryColumnFieldCollection fieldCollection) { + + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesValueCorrelationDefinition.setFilterProperties(updateSeries()); + } + + List categoryList = fieldCollection.getCategoryList(); + if (!categoryList.isEmpty()) { + categoryList.get(0).setFilterProperties(updateCategory()); + } + } + + private void populateSeries(DataFilterProperties series) { + seriesFilterPane.populateBean(series); + + } + + private void populateCategory(DataFilterProperties category) { + categoryFilterPane.populateBean(category); + + } + + private DataFilterProperties updateSeries() { + return seriesFilterPane.updateBean(); + + } + + private DataFilterProperties updateCategory() { + return categoryFilterPane.updateBean(); + } + + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesXYValueCorrelationPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesXYValueCorrelationPane.java new file mode 100644 index 0000000000..06a02154e8 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesXYValueCorrelationPane.java @@ -0,0 +1,66 @@ +package com.fr.design.chartx.component; + +import com.fr.base.Utils; +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.diff.BubbleColumnField; +import com.fr.chartx.data.field.diff.BubbleColumnFieldCollection; +import com.fr.design.chartx.component.correlation.AbstractCorrelationPane; +import com.fr.design.chartx.component.correlation.FieldEditorComponentWrapper; +import com.fr.design.chartx.component.correlation.TinyFormulaPaneEditorComponent; +import com.fr.design.i18n.Toolkit; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Wim on 2019/11/04. + */ +public class CellDataSeriesXYValueCorrelationPane extends AbstractCorrelationPane { + + @Override + protected FieldEditorComponentWrapper[] createFieldEditorComponentWrappers() { + return new FieldEditorComponentWrapper[]{ + new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Name")), + new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_X_Axis")), + new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Y_Axis")), + new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Value")) + }; + } + + @Override + protected List covertTBeanToTableModelList(BubbleColumnFieldCollection bubbleColumnFieldCollection) { + List result = new ArrayList<>(); + + List bubbleColumnFieldList = bubbleColumnFieldCollection.getList(); + for (BubbleColumnField field : bubbleColumnFieldList) { + Object[] array = new Object[]{ + field.getSeriesName().getFieldName(), + field.getXField().getFieldName(), + field.getYField().getFieldName(), + field.getValueField().getFieldName() + }; + result.add(array); + } + + return result; + } + + @Override + protected void setTableModelListToTBean(List tableValues, BubbleColumnFieldCollection bubbleColumnFieldCollection) { + List bubbleColumnFieldList = new ArrayList<>(); + for (Object[] oneLine : tableValues) { + BubbleColumnField bubbleColumnField = new BubbleColumnField(); + ColumnField series = new ColumnField(Utils.objectToString(oneLine[0])); + ColumnField xField = new ColumnField(Utils.objectToString(oneLine[1])); + ColumnField yField = new ColumnField(Utils.objectToString(oneLine[2])); + ColumnField value = new ColumnField(Utils.objectToString(oneLine[3])); + bubbleColumnField.setSeriesName(series); + bubbleColumnField.setXField(xField); + bubbleColumnField.setYField(yField); + bubbleColumnField.setValueField(value); + bubbleColumnFieldList.add(bubbleColumnField); + } + + bubbleColumnFieldCollection.setList(bubbleColumnFieldList); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/HyperLinkPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/HyperLinkPane.java new file mode 100644 index 0000000000..c1ff699742 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/HyperLinkPane.java @@ -0,0 +1,207 @@ +package com.fr.design.chartx.component; + +import com.fr.base.BaseFormula; +import com.fr.chart.web.ChartHyperPoplink; +import com.fr.chart.web.ChartHyperRelateCellLink; +import com.fr.chart.web.ChartHyperRelateFloatLink; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.javascript.ChartEmailPane; +import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperPoplinkPane; +import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateCellLinkPane; +import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateFloatLinkPane; +import com.fr.design.chart.series.SeriesCondition.impl.FormHyperlinkPane; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.fun.HyperlinkProvider; +import com.fr.design.gui.controlpane.NameObjectCreator; +import com.fr.design.gui.controlpane.NameableCreator; +import com.fr.design.gui.controlpane.UIListControlPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.hyperlink.ReportletHyperlinkPane; +import com.fr.design.hyperlink.WebHyperlinkPane; +import com.fr.design.i18n.Toolkit; +import com.fr.design.javascript.JavaScriptImplPane; +import com.fr.design.javascript.ParameterJavaScriptPane; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.general.NameObject; +import com.fr.js.EmailJavaScript; +import com.fr.js.FormHyperlinkProvider; +import com.fr.js.JavaScript; +import com.fr.js.JavaScriptImpl; +import com.fr.js.NameJavaScript; +import com.fr.js.NameJavaScriptGroup; +import com.fr.js.ParameterJavaScript; +import com.fr.js.ReportletHyperlink; +import com.fr.js.WebHyperlink; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.Nameable; +import com.fr.stable.bridge.StableFactory; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.JPanel; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-09-25 + */ +public class HyperLinkPane extends UIListControlPane implements UIObserver { + + private Map hyperLinkEditorMap; + + private UIObserverListener uiObserverListener; + + public HyperLinkPane() { + super(); + this.setBorder(null); + } + + @Override + public NameableCreator[] createNameableCreators() { + List creators = new ArrayList(); + + creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Link_Reportlet"), + ReportletHyperlink.class, ReportletHyperlinkPane.class)); + creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Link_Mail"), EmailJavaScript.class, NewChartEmailPane.class)); + creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Link_Web"), + WebHyperlink.class, WebHyperlinkPane.class)); + creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Link_Dynamic_Parameters"), + ParameterJavaScript.class, ParameterJavaScriptPane.class)); + creators.add(new NameObjectCreator("JavaScript", JavaScriptImpl.class, JavaScriptImplPane.class)); + + creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Float_Chart"), + ChartHyperPoplink.class, ChartHyperPoplinkPane.class)); + creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Link_Cell"), + ChartHyperRelateCellLink.class, ChartHyperRelateCellLinkPane.class)); + creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Link_Float"), + ChartHyperRelateFloatLink.class, ChartHyperRelateFloatLinkPane.class)); + + FormHyperlinkProvider hyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); + creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Link_Form"), + hyperlink.getClass(), FormHyperlinkPane.class)); + + Set providers = ExtraDesignClassManager.getInstance().getArray(HyperlinkProvider.XML_TAG); + for (HyperlinkProvider provider : providers) { + NameableCreator nc = provider.createHyperlinkCreator(); + creators.add(nc); + } + + return creators.toArray(new NameableCreator[creators.size()]); + } + + public BasicBeanPane createPaneByCreators(NameableCreator creator) { + Constructor constructor; + try { + constructor = creator.getUpdatePane().getConstructor(HashMap.class, boolean.class); + return constructor.newInstance(hyperLinkEditorMap, false); + + } catch (InstantiationException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } catch (IllegalAccessException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } catch (NoSuchMethodException e) { + return super.createPaneByCreators(creator); + } catch (InvocationTargetException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return null; + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + uiObserverListener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + @Override + protected JPanel getLeftTopPane(UIToolbar topToolBar) { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] columnSize = {f, e}; + double[] rowSize = {p}; + Component[][] components = new Component[][]{ + new Component[]{new UILabel(getAddItemText()), topToolBar}, + }; + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + } + + @Override + public void saveSettings() { + if (isPopulating) { + return; + } + uiObserverListener.doChange(); + } + + public void update(NameJavaScriptGroup nameGroup) { + + Nameable[] nameables = update(); + + nameGroup.clear(); + + for (int i = 0; i < nameables.length; i++) { + JavaScript javaScript = (JavaScript) ((NameObject) nameables[i]).getObject(); + String name = nameables[i].getName(); + NameJavaScript nameJava = new NameJavaScript(name, javaScript); + nameGroup.addNameHyperlink(nameJava); + } + + } + + public void populate(NameJavaScriptGroup nameGroup, Map hyperLinkEditorMap) { + + this.hyperLinkEditorMap = hyperLinkEditorMap; + + List nameObjects = new ArrayList(); + + for (int i = 0; nameGroup != null && i < nameGroup.size(); i++) { + NameJavaScript javaScript = nameGroup.getNameHyperlink(i); + if (javaScript != null && javaScript.getJavaScript() != null) { + JavaScript script = javaScript.getJavaScript(); + nameObjects.add(new NameObject(javaScript.getName(), script)); + } + } + + this.populate(nameObjects.toArray(new NameObject[nameObjects.size()])); + doLayout(); + } + + /** + * 弹出列表的标题. + * + * @return 返回标题字符串. + */ + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Report_Hyperlink"); + } + + @Override + protected String getAddItemText() { + return Toolkit.i18nText("Fine-Design_Basic_Add_Hyperlink"); + } + + //邮箱 + public static class NewChartEmailPane extends ChartEmailPane { + @Override + protected boolean needRenamePane() { + return false; + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java index 5e56b967c4..6a32cba2b2 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java @@ -8,6 +8,12 @@ import com.fr.design.formula.TinyFormulaPane; * Created by shine on 2019/4/12. */ public class MultiTinyFormulaPane extends AbstractMultiComponentPane { + + @Override + protected int componentWidth() { + return 116; + } + @Override protected TinyFormulaPane createFirstFieldComponent() { return new TinyFormulaPane(); diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java index 21f86633ac..1ac1952aa0 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java @@ -1,6 +1,6 @@ package com.fr.design.chartx.fields.diff; -import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithSeriesValue; +import com.fr.chartx.data.field.diff.ColumnFieldCollectionWithSeriesValue; import com.fr.design.chartx.component.CellDataSeriesValueCorrelationPane; import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; @@ -10,7 +10,7 @@ import java.awt.BorderLayout; /** * Created by shine on 2019/6/4. */ -public abstract class AbstractCellDataFieldsWithSeriesValuePane +public abstract class AbstractCellDataFieldsWithSeriesValuePane extends AbstractCellDataFieldsPane { private CellDataSeriesValueCorrelationPane seriesValueFieldsPane; @@ -41,11 +41,11 @@ public abstract class AbstractCellDataFieldsWithSeriesValuePane +public abstract class AbstractDataSetFieldsWithSeriesValuePane extends AbstractDataSetFieldsPane { private SeriesValueFieldComboBoxPane seriesValueFieldComboBoxPane; @@ -61,11 +61,11 @@ public abstract class AbstractDataSetFieldsWithSeriesValuePane { + + private AbstractSingleFilterPane filterPane; + + @Override + protected void initComponents() { + filterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Series"); + } + }; + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(createCenterPane(), BorderLayout.CENTER); + northPane.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(new JPanel(), BorderLayout.NORTH); + contentPane.add(filterPane, BorderLayout.CENTER); + this.add(TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), contentPane), BorderLayout.CENTER); + } + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[0]; + } + + @Override + public ColumnFieldCollectionWithSeriesValue updateBean() { + ColumnFieldCollectionWithSeriesValue fieldCollection = new ColumnFieldCollectionWithSeriesValue(); + updateSeriesValuePane(fieldCollection); + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition(); + filterPane.updateBean(seriesValueCorrelationDefinition.getFilterProperties()); + return fieldCollection; + } + + @Override + public void populateBean(ColumnFieldCollectionWithSeriesValue ob) { + populateSeriesValuePane(ob); + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = ob.getSeriesValueCorrelationDefinition(); + filterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/FunnelDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/FunnelDataSetFieldsPane.java new file mode 100644 index 0000000000..c24a23b4e8 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/FunnelDataSetFieldsPane.java @@ -0,0 +1,70 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; +import com.fr.chartx.data.field.diff.ColumnFieldCollectionWithSeriesValue; +import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import java.awt.BorderLayout; + +/** + * Created by Wim on 2019/10/23. + */ +public class FunnelDataSetFieldsPane extends AbstractDataSetFieldsWithSeriesValuePane { + + + private AbstractSingleFilterPane filterPane; + + @Override + protected void initComponents() { + filterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Series"); + } + }; + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(new JSeparator(), BorderLayout.CENTER); + northPane.add(createCenterPane(), BorderLayout.SOUTH); + northPane.setBorder(BorderFactory.createEmptyBorder(4, 24, 0, 15)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(new JPanel(), BorderLayout.NORTH); + contentPane.add(filterPane, BorderLayout.CENTER); + this.add(TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), contentPane), BorderLayout.CENTER); + } + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + return new UIComboBox[0]; + } + + @Override + public ColumnFieldCollectionWithSeriesValue updateBean() { + ColumnFieldCollectionWithSeriesValue collection = new ColumnFieldCollectionWithSeriesValue(); + updateSeriesValuePane(collection); + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = collection.getSeriesValueCorrelationDefinition(); + filterPane.updateBean(seriesValueCorrelationDefinition.getFilterProperties()); + return collection; + } + + @Override + public void populateBean(ColumnFieldCollectionWithSeriesValue ob) { + populateSeriesValuePane(ob); + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = ob.getSeriesValueCorrelationDefinition(); + filterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/GaugeCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/GaugeCellDataFieldsPane.java new file mode 100644 index 0000000000..5df78ff2ba --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/GaugeCellDataFieldsPane.java @@ -0,0 +1,82 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.GaugeColumnFieldCollection; +import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * Created by Wim on 2019/11/07. + */ +public class GaugeCellDataFieldsPane extends AbstractCellDataFieldsPane { + + private TinyFormulaPane category; + private TinyFormulaPane value; + private AbstractSingleFilterPane filterPane; + + @Override + protected void initComponents() { + category = new TinyFormulaPane(); + value = new TinyFormulaPane(); + + filterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Category"); + } + }; + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(createCenterPane(), BorderLayout.CENTER); + northPane.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(new JPanel(), BorderLayout.NORTH); + contentPane.add(filterPane, BorderLayout.CENTER); + this.add(TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), contentPane), BorderLayout.CENTER); + } + + @Override + protected JPanel createSouthPane() { + return filterPane; + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Style_Format_Category_Name"), + Toolkit.i18nText("Fine-Design_Chart_Pointer_Value") + }; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[]{ + category, value + }; + } + + @Override + public GaugeColumnFieldCollection updateBean() { + GaugeColumnFieldCollection gauge = new GaugeColumnFieldCollection(); + updateField(category, gauge.getCategory()); + updateField(value, gauge.getValue()); + filterPane.updateBean(gauge.getCategory().getFilterProperties()); + return gauge; + } + + @Override + public void populateBean(GaugeColumnFieldCollection ob) { + populateField(category, ob.getCategory()); + populateField(value, ob.getValue()); + filterPane.populateBean(ob.getCategory().getFilterProperties()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/GaugeDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/GaugeDataSetFieldsPane.java new file mode 100644 index 0000000000..9c09cc63cb --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/GaugeDataSetFieldsPane.java @@ -0,0 +1,84 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.GaugeColumnFieldCollection; +import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import java.awt.BorderLayout; + +/** + * Created by Wim on 2019/11/07. + */ +public class GaugeDataSetFieldsPane extends AbstractDataSetFieldsPane { + + private UIComboBox category; + private UIComboBox value; + + private AbstractSingleFilterPane filterPane; + + + @Override + protected void initComponents() { + category = new UIComboBox(); + value = new UIComboBox(); + + filterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Category"); + } + }; + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(new JSeparator(), BorderLayout.CENTER); + northPane.add(createCenterPane(), BorderLayout.SOUTH); + northPane.setBorder(BorderFactory.createEmptyBorder(4, 24, 0, 15)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(new JPanel(), BorderLayout.NORTH); + contentPane.add(filterPane, BorderLayout.CENTER); + this.add(TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), contentPane), BorderLayout.CENTER); + + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Style_Format_Category_Name"), + Toolkit.i18nText("Fine-Design_Chart_Pointer_Value") + }; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + return new UIComboBox[]{ + category, value + }; + } + + @Override + public GaugeColumnFieldCollection updateBean() { + GaugeColumnFieldCollection gauge = new GaugeColumnFieldCollection(); + updateField(category, gauge.getCategory()); + updateField(value, gauge.getValue()); + filterPane.updateBean(gauge.getCategory().getFilterProperties()); + return gauge; + } + + @Override + public void populateBean(GaugeColumnFieldCollection ob) { + populateField(category, ob.getCategory()); + populateField(value, ob.getValue()); + filterPane.populateBean(ob.getCategory().getFilterProperties()); + } + + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java index 3645a08db7..c4d133a635 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java @@ -1,14 +1,14 @@ package com.fr.design.chartx.fields.diff; import com.fr.chartx.data.field.ColumnField; -import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; -import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.chartx.component.CategorySeriesFilterPane; import com.fr.design.chartx.component.MultiTinyFormulaPane; import com.fr.design.formula.TinyFormulaPane; -import com.fr.van.chart.map.designer.VanChartGroupPane; +import javax.swing.BorderFactory; import javax.swing.JPanel; +import java.awt.BorderLayout; import java.util.List; /** @@ -18,43 +18,21 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS private MultiTinyFormulaPane multiCategoryPane; - private AbstractSingleFilterPane seriesFilterPane; - private AbstractSingleFilterPane categoryFilterPane; - - private void createMultiFormulaPane() { - if (multiCategoryPane == null) { - multiCategoryPane = new MultiTinyFormulaPane(); - } - } - - @Override - protected JPanel createNorthPane() { - - createMultiFormulaPane(); - - return multiCategoryPane; - } + private CategorySeriesFilterPane filterPane; @Override - protected JPanel createSouthPane() { - if (seriesFilterPane == null) { - seriesFilterPane = new AbstractSingleFilterPane() { - @Override - public String title4PopupWindow() { - //todo@shinerefactor - return "series"; - } - }; - categoryFilterPane = new AbstractSingleFilterPane() { - @Override - public String title4PopupWindow() { - return "category"; - } - }; - } - return new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()} - , new JPanel[]{seriesFilterPane, categoryFilterPane}) { - }; + protected void initComponents() { + multiCategoryPane = new MultiTinyFormulaPane(); + filterPane = new CategorySeriesFilterPane(); + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(multiCategoryPane, BorderLayout.NORTH); + northPane.add(createCenterPane(), BorderLayout.CENTER); + northPane.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + this.add(filterPane, BorderLayout.CENTER); } @Override @@ -64,9 +42,6 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS @Override protected TinyFormulaPane[] formulaPanes() { - - createMultiFormulaPane(); - List list = multiCategoryPane.componentList(); return list.toArray(new TinyFormulaPane[list.size()]); } @@ -80,15 +55,7 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS populateSeriesValuePane(multiCategoryColumnFieldCollection); - SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition(); - if (seriesValueCorrelationDefinition != null) { - seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); - - } - - if (categoryList != null && !categoryList.isEmpty()) { - categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties()); - } + filterPane.populateMultiCategoryFieldCollection(multiCategoryColumnFieldCollection); } @Override @@ -101,14 +68,7 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS updateSeriesValuePane(fieldCollection); - SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition(); - if (seriesValueCorrelationDefinition != null) { - seriesValueCorrelationDefinition.setFilterProperties(seriesFilterPane.updateBean()); - } - - if (categoryList != null && !categoryList.isEmpty()) { - categoryList.get(0).setFilterProperties(categoryFilterPane.updateBean()); - } + filterPane.updateMultiCategoryFieldCollection(fieldCollection); return fieldCollection; } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java index 5b18d8ae83..911db920ca 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java @@ -1,14 +1,15 @@ package com.fr.design.chartx.fields.diff; import com.fr.chartx.data.field.ColumnField; -import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; -import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.chartx.component.CategorySeriesFilterPane; import com.fr.design.chartx.component.MultiComboBoxPane; import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.van.chart.map.designer.VanChartGroupPane; +import javax.swing.BorderFactory; import javax.swing.JPanel; +import javax.swing.JSeparator; +import java.awt.BorderLayout; import java.util.List; @@ -19,8 +20,23 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer private MultiComboBoxPane multiCategoryPane; - private AbstractSingleFilterPane seriesFilterPane; - private AbstractSingleFilterPane categoryFilterPane; + private CategorySeriesFilterPane filterPane; + + @Override + protected void initComponents() { + multiCategoryPane = new MultiComboBoxPane(); + filterPane = new CategorySeriesFilterPane(); + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(multiCategoryPane, BorderLayout.NORTH); + northPane.add(new JSeparator(), BorderLayout.CENTER); + northPane.add(createCenterPane(), BorderLayout.SOUTH); + northPane.setBorder(BorderFactory.createEmptyBorder(4, 24, 0, 15)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + this.add(filterPane, BorderLayout.CENTER); + } @Override protected String[] fieldLabels() { @@ -29,44 +45,10 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer @Override protected UIComboBox[] filedComboBoxes() { - List list = initMultiCategoryPane().componentList(); + List list = multiCategoryPane.componentList(); return list.toArray(new UIComboBox[list.size()]); } - private MultiComboBoxPane initMultiCategoryPane() { - if (multiCategoryPane == null) { - multiCategoryPane = new MultiComboBoxPane(); - } - return multiCategoryPane; - } - - @Override - protected JPanel createNorthPane() { - return initMultiCategoryPane(); - } - - @Override - protected JPanel createSouthPane() { - if (seriesFilterPane == null) { - seriesFilterPane = new AbstractSingleFilterPane() { - @Override - public String title4PopupWindow() { - //todo@shinerefactor - return "series"; - } - }; - categoryFilterPane = new AbstractSingleFilterPane() { - @Override - public String title4PopupWindow() { - return "category"; - } - }; - } - return new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()} - , new JPanel[]{seriesFilterPane, categoryFilterPane}) { - }; - } - @Override public void refreshBoxListWithSelectTableData(List columnNameList) { super.refreshBoxListWithSelectTableData(columnNameList); @@ -81,15 +63,7 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer populateSeriesValuePane(multiCategoryColumnFieldCollection); - SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition(); - if (seriesValueCorrelationDefinition != null) { - seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); - - } - - if (categoryList != null && !categoryList.isEmpty()) { - categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties()); - } + filterPane.populateMultiCategoryFieldCollection(multiCategoryColumnFieldCollection); } @Override @@ -102,14 +76,7 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer updateSeriesValuePane(columnFieldCollection); - SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = columnFieldCollection.getSeriesValueCorrelationDefinition(); - if (seriesValueCorrelationDefinition != null) { - seriesValueCorrelationDefinition.setFilterProperties(seriesFilterPane.updateBean()); - } - - if (categoryList != null && !categoryList.isEmpty()) { - categoryList.get(0).setFilterProperties(categoryFilterPane.updateBean()); - } + filterPane.updateMultiCategoryFieldCollection(columnFieldCollection); return columnFieldCollection; } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java index 950f49401a..32ab6e604c 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java @@ -4,10 +4,19 @@ import com.fr.chartx.data.field.diff.MultiPieColumnFieldCollection; import com.fr.design.chartx.component.MultiTinyFormulaPaneWithUISpinner; import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import javax.swing.BorderFactory; import javax.swing.JPanel; +import javax.swing.JSeparator; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; /** * Created by shine on 2019/6/18. @@ -30,7 +39,18 @@ public class MultiPieCellDataFieldsPane extends AbstractCellDataFieldsPane { + + private CellDataSeriesXYValueCorrelationPane seriesXYValueCorrelationPane; + private AbstractSingleFilterPane filterPane; + + + public CellDataSeriesXYValueCorrelationPane getSeriesXYValueCorrelationPane() { + return seriesXYValueCorrelationPane; + } + + public void setSeriesXYValueCorrelationPane(CellDataSeriesXYValueCorrelationPane seriesXYValueCorrelationPane) { + this.seriesXYValueCorrelationPane = seriesXYValueCorrelationPane; + } + + @Override + protected void initComponents() { + filterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Series"); + } + }; + + this.setLayout(new BorderLayout(0, 6)); + this.add(createCenterPane(), BorderLayout.NORTH); + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(new JPanel(), BorderLayout.NORTH); + contentPane.add(filterPane, BorderLayout.CENTER); + this.add(TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), contentPane), BorderLayout.CENTER); + + } + + @Override + protected JPanel createCenterPane() { + JPanel normalCenter = super.createCenterPane(); + seriesXYValueCorrelationPane = new CellDataSeriesXYValueCorrelationPane(); + + if (normalCenter != null) { + JPanel panel = new JPanel(new BorderLayout(0, 6)); + panel.add(normalCenter, BorderLayout.NORTH); + panel.add(seriesXYValueCorrelationPane, BorderLayout.CENTER); + return panel; + } else { + return seriesXYValueCorrelationPane; + } + + } + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[0]; + } + + @Override + public BubbleColumnFieldCollection updateBean() { + BubbleColumnFieldCollection collection = new BubbleColumnFieldCollection(); + seriesXYValueCorrelationPane.updateBean(collection); + return collection; + } + + @Override + public void populateBean(BubbleColumnFieldCollection ob) { + seriesXYValueCorrelationPane.populateBean(ob); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/ScatterDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/ScatterDataSetFieldsPane.java new file mode 100644 index 0000000000..79765cccb3 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/ScatterDataSetFieldsPane.java @@ -0,0 +1,95 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.BubbleColumnField; +import com.fr.chartx.data.field.diff.BubbleColumnFieldCollection; +import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; +import com.fr.extended.chart.UIComboBoxWithNone; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import java.awt.BorderLayout; + +/** + * Created by Wim on 2019/10/29. + */ +public class ScatterDataSetFieldsPane extends AbstractDataSetFieldsPane { + + private UIComboBoxWithNone series; + private UIComboBox xField; + private UIComboBox yField; + private UIComboBoxWithNone value; + + //todo 数据筛选 + private AbstractSingleFilterPane filterPane; + + + @Override + protected void initComponents() { + + series = new UIComboBoxWithNone(); + xField = new UIComboBox(); + yField = new UIComboBox(); + value = new UIComboBoxWithNone(); + + filterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Series"); + } + }; + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(new JSeparator(), BorderLayout.CENTER); + northPane.add(createCenterPane(), BorderLayout.SOUTH); + northPane.setBorder(BorderFactory.createEmptyBorder(4, 24, 0, 15)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(new JPanel(), BorderLayout.NORTH); + contentPane.add(filterPane, BorderLayout.CENTER); + this.add(TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), contentPane), BorderLayout.CENTER); + } + + @Override + protected UIComboBox[] filedComboBoxes() { + return new UIComboBox[]{ + series, xField, yField, value + }; + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Series_Name"), + "x", + "y", + Toolkit.i18nText("Fine-Design_Chart_Use_Value") + }; + } + + @Override + public BubbleColumnFieldCollection updateBean() { + BubbleColumnFieldCollection collection = new BubbleColumnFieldCollection(); + BubbleColumnField field = collection.getBubbleColumnField(0); + updateField(series, field.getSeriesName()); + updateField(xField, field.getXField()); + updateField(yField, field.getYField()); + updateField(value, field.getValueField()); + return collection; + } + + @Override + public void populateBean(BubbleColumnFieldCollection ob) { + BubbleColumnField field = ob.getBubbleColumnField(0); + populateField(series, field.getSeriesName()); + populateField(xField, field.getXField()); + populateField(yField, field.getYField()); + populateField(value, field.getValueField()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryCellDataFieldsPane.java new file mode 100644 index 0000000000..dc90ee09f0 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryCellDataFieldsPane.java @@ -0,0 +1,84 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; +import com.fr.design.chartx.component.CategorySeriesFilterPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.ilable.BoldFontTextLabel; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-10-24 + */ +public class SingleCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithSeriesValuePane { + + private TinyFormulaPane categoryPane; + + private CategorySeriesFilterPane filterPane; + + @Override + protected void initComponents() { + categoryPane = new TinyFormulaPane(); + filterPane = new CategorySeriesFilterPane(); + + UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Style_Category")); + label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryPane, null, null, label, null}), BorderLayout.NORTH); + northPane.add(createCenterPane(), BorderLayout.CENTER); + northPane.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + this.add(filterPane, BorderLayout.CENTER); + } + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[]{categoryPane}; + } + + @Override + public void populateBean(MultiCategoryColumnFieldCollection fieldCollection) { + if (fieldCollection.getCategoryList().size() > 0) { + populateField(categoryPane, fieldCollection.getCategoryList().get(0)); + } + + populateSeriesValuePane(fieldCollection); + + filterPane.populateMultiCategoryFieldCollection(fieldCollection); + } + + @Override + public MultiCategoryColumnFieldCollection updateBean() { + + MultiCategoryColumnFieldCollection fieldCollection = new MultiCategoryColumnFieldCollection(); + fieldCollection.getCategoryList().add(new ColumnField()); + + updateField(categoryPane, fieldCollection.getCategoryList().get(0)); + + updateSeriesValuePane(fieldCollection); + + filterPane.updateMultiCategoryFieldCollection(fieldCollection); + + return fieldCollection; + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryDataSetFieldsPane.java new file mode 100644 index 0000000000..07936dfcb2 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryDataSetFieldsPane.java @@ -0,0 +1,88 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; +import com.fr.design.chartx.component.CategorySeriesFilterPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.BoldFontTextLabel; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.extended.chart.UIComboBoxWithNone; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-10-24 + */ +public class SingleCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSeriesValuePane { + + private UIComboBox categoryPane; + + private CategorySeriesFilterPane filterPane; + + @Override + protected void initComponents() { + categoryPane = new UIComboBoxWithNone(); + filterPane = new CategorySeriesFilterPane(); + + UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Style_Category")); + label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryPane, null, null, label, null}), BorderLayout.NORTH); + northPane.add(new JSeparator(), BorderLayout.CENTER); + northPane.add(createCenterPane(), BorderLayout.SOUTH); + northPane.setBorder(BorderFactory.createEmptyBorder(4, 24, 0, 15)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + this.add(filterPane, BorderLayout.CENTER); + } + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + return new UIComboBox[]{categoryPane}; + } + + + @Override + public void populateBean(MultiCategoryColumnFieldCollection columnFieldCollection) { + if (columnFieldCollection.getCategoryList().size() > 0) { + populateField(categoryPane, columnFieldCollection.getCategoryList().get(0)); + } + + populateSeriesValuePane(columnFieldCollection); + + filterPane.populateMultiCategoryFieldCollection(columnFieldCollection); + } + + @Override + public MultiCategoryColumnFieldCollection updateBean() { + + MultiCategoryColumnFieldCollection columnFieldCollection = new MultiCategoryColumnFieldCollection(); + columnFieldCollection.getCategoryList().add(new ColumnField()); + + updateField(categoryPane, columnFieldCollection.getCategoryList().get(0)); + + updateSeriesValuePane(columnFieldCollection); + + filterPane.updateMultiCategoryFieldCollection(columnFieldCollection); + + return columnFieldCollection; + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/StructureCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/StructureCellDataFieldsPane.java index 87ff4d3954..b9db310625 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/StructureCellDataFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/StructureCellDataFieldsPane.java @@ -59,7 +59,7 @@ public class StructureCellDataFieldsPane extends AbstractCellDataFieldsPane 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/ChartDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java index 5aed1e47d6..ad549c5afd 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java @@ -11,8 +11,8 @@ import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.data.DataContentsPane; import com.fr.design.mainframe.chart.gui.data.NormalChartDataPane; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import java.awt.BorderLayout; public class ChartDataPane extends AbstractChartAttrPane { @@ -35,6 +35,7 @@ public class ChartDataPane extends AbstractChartAttrPane { return contentsPane; } + /** * 界面标题 */ 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 4dedb133d3..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 @@ -3,7 +3,6 @@ package com.fr.design.mainframe.chart.gui; import com.fr.base.BaseUtils; import com.fr.chart.base.AttrChangeConfig; import com.fr.chart.chartattr.ChartCollection; -import com.fr.chart.chartattr.SwitchState; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chartx.attr.ChartProvider; import com.fr.design.beans.BasicBeanPane; @@ -177,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); @@ -187,12 +186,6 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private void calculateMultiChartMode() { //设置切换功能是否可用 editingCollection.getChangeConfigAttr().setEnable(changeEnable()); - //多图表切换模式 - if (editingCollection.getChartCount() > 1) { - editingCollection.setState(SwitchState.CHANGE); - } else { - editingCollection.setState(SwitchState.DEFAULT); - } } /** @@ -206,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() { @@ -361,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.getState() == SwitchState.DEFAULT && editingCollection.getSelectedChartProvider() != null) { + if (editingCollection.getChartCount() == 1 && editingCollection.getSelectedChartProvider(ChartProvider.class) != null) { //Chart 不支持图表切换 configButton.setVisible(supportChange()); } @@ -491,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++) { @@ -571,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 e9dcbedce3..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 @@ -1,7 +1,6 @@ package com.fr.design.mainframe.chart.gui; import com.fr.chart.chartattr.ChartCollection; -import com.fr.chart.chartattr.SwitchState; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chartx.attr.ChartProvider; import com.fr.design.ChartTypeInterfaceManager; @@ -125,7 +124,8 @@ public class ChartTypePane extends AbstractChartAttrPane{ String lastPlotID = chart.getID(); try{ - ChartProvider newDefaultChart = (ChartProvider) ((AbstractChartTypePane) getSelectedPane()).getDefaultChart().clone(); + AbstractChartTypePane selectedPane = (AbstractChartTypePane) getSelectedPane(); + ChartProvider newDefaultChart =(ChartProvider) ChartTypeManager.getInstanceWithCheck().getCharts(selectedPane.getPlotID())[0].clone(); if (!ComparatorUtils.equals(chart.getClass(), newDefaultChart.getClass())) { //vanChart 和 chart 之间切换 //不同chart之间切换 @@ -136,7 +136,6 @@ public class ChartTypePane extends AbstractChartAttrPane{ }catch (CloneNotSupportedException e){ FineLoggerFactory.getLogger().error(e.getMessage(), e); } - //这一步会替换plot ((AbstractChartTypePane)getSelectedPane()).updateBean(chart); @@ -209,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); @@ -218,7 +217,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ //第一步就是重构cards cards.clear(); if (enabledChart) { - if (collection.getState() == SwitchState.DEFAULT) { + if (collection.getChartCount() == 1) { addAllCards(); } else { addOnePriorityCards(priority); @@ -295,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))){ @@ -316,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(); @@ -334,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/style/series/ColorPickerPaneNumFiled.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ColorPickerPaneNumFiled.java index 267a8a847f..fcaed6d990 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ColorPickerPaneNumFiled.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ColorPickerPaneNumFiled.java @@ -1,9 +1,13 @@ package com.fr.design.mainframe.chart.gui.style.series; -import java.util.Timer; -import java.util.TimerTask; - +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.gui.itextfield.UINumberField; +import com.fr.module.ModuleContext; +import com.fr.value.ClearableLazyValue; +import org.jetbrains.annotations.NotNull; + +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; /** * Created with IntelliJ IDEA. @@ -13,28 +17,34 @@ import com.fr.design.gui.itextfield.UINumberField; * To change this template use File | Settings | File Templates. */ public class ColorPickerPaneNumFiled extends UINumberField { - private Timer timer; + private ClearableLazyValue ses = new ClearableLazyValue() { + @NotNull + @Override + protected ScheduledExecutorService compute() { + return ModuleContext.getExecutor() + .newSingleThreadScheduledExecutor(new NamedThreadFactory("FormatePaneNumFieldRunChange")); + } + }; + public ColorPickerPaneNumFiled() { super(); } + @Override protected void attributeChange() { - if(timer != null){ - timer.cancel(); - } - timer = new Timer(); - timer.schedule(new TimerTask() { + ses.getValue().schedule(new Runnable() { @Override public void run() { + // kuns: 默认修改500, 在地图修改系列颜色text时, 快速响应. runChange(); } - },500);// kuns: 默认修改500, 在地图修改系列颜色text时, 快速响应. - + }, 500, TimeUnit.MILLISECONDS); } - protected void runChange(){ + protected void runChange() { super.attributeChange(); - timer.cancel(); + ses.getValue().shutdown(); + ses.drop(); } 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..2259389fab 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 @@ -25,7 +25,7 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { private static final long serialVersionUID = 2595221900000305396L; private static final int GISMAP = 0; - + private UITextField keyInput; public GisMapPlotPane(){ @@ -34,7 +34,7 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { Component[][] components = null; styleList = createStyleList(); - + checkDemosBackground(); JPanel layoutPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(4); @@ -45,7 +45,7 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { tmp.setDemoGroup(styleList.toArray(new ChartSelectDemoPane[styleList.size()])); } } - + keyInput = new UITextField(); double[] columnSize = { f }; @@ -58,16 +58,16 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { new Component[]{keyInput}, }; } - + JPanel panel = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); this.setLayout(new BorderLayout()); this.add(panel,BorderLayout.CENTER); - + } @Override public void reLayout(String chartID){ - + //do nothing } @Override @@ -88,6 +88,12 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { return ChartConstants.GIS_CHAER; } + @Override + public String getPlotID() { + return ChartConstants.GIS_CHAER; + } + + @Override protected String[] getTypeLayoutPath() { return new String[]{"/com/fr/design/images/chart/GisMapPlot/layout/0.png", "/com/fr/design/images/chart/GisMapPlot/layout/1.png", @@ -105,6 +111,7 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { /** * 保存界面属性 */ + @Override public void updateBean(Chart chart) { if(needsResetChart(chart)){ resetChart(chart); @@ -121,14 +128,14 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { } else { plot = new GisMapPlot(); } - + try { chart.switchPlot((Plot)plot.clone()); } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error("Error In LineChart"); chart.switchPlot(new GisMapPlot()); } - + plot = (GisMapPlot) chart.getPlot(); boolean index = plot.isGisType(); if(styleList.get(BAIDU).isPressing){ @@ -136,7 +143,7 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { }else{ plot.setGisType(false); } - + if(index != plot.isGisType()){ if(plot.isGisType()){ this.keyInput.setText(plot.getBaiduKey()); @@ -156,15 +163,15 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { /** * 更新界面内容 */ + @Override public void populateBean(Chart chart) { - typeDemo.get(0).isPressing = true; GisMapPlot plot = (GisMapPlot) chart.getPlot(); if(plot.isGisType()){ styleList.get(BAIDU).isPressing = true; styleList.get(GOOGLE).isPressing = false; keyInput.setText(plot.getBaiduKey()); - + }else{ styleList.get(GOOGLE).isPressing = true; styleList.get(BAIDU).isPressing =false; @@ -178,6 +185,7 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { * 界面标题 * @return 标题 */ + @Override public String title4PopupWindow() { return Toolkit.i18nText("Fine-Design_Chart_GIS_Map_OLD"); } @@ -191,7 +199,8 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { } - public Chart getDefaultChart() { + @Override + public Chart getDefaultChart() { return GisMapIndependentChart.gisChartTypes[0]; } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java index 2d9ebb5dc1..d373eab4e8 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java @@ -67,7 +67,7 @@ public class ExtendedTypePane extends AbstractChartType @Override public ChartProvider getDefaultChart() { - return ChartTypeManager.getInstance().getChartTypes(getPlotID())[0]; + return ChartTypeManager.getInstance().getCharts(getPlotID())[0]; } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java index abf6ca31ce..d8b3b6de5f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java @@ -15,15 +15,15 @@ public class VanChartAreaSeriesPane extends VanChartLineSeriesPane { private static final long serialVersionUID = 5497989595104913025L; - public VanChartAreaSeriesPane(ChartStylePane parent, Plot plot){ + public VanChartAreaSeriesPane(ChartStylePane parent, Plot plot) { super(parent, plot); } - protected JPanel getContentInPlotType(){ + protected JPanel getContentInPlotType() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] row = {p,p,p,p,p,p,p}; + double[] row = {p, p, p, p, p, p, p}; double[] col = {f}; Component[][] components = new Component[][]{ @@ -32,7 +32,6 @@ public class VanChartAreaSeriesPane extends VanChartLineSeriesPane { new Component[]{createMarkerPane()}, new Component[]{createAreaFillColorPane()}, new Component[]{createStackedAndAxisPane()}, - new Component[]{createLargeDataModelPane()}, new Component[]{createTrendLinePane()}, }; diff --git a/designer-chart/src/main/java/com/fr/van/chart/bar/BarIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/bar/BarIndependentVanChartInterface.java index 0321132b32..63a8e7640c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bar/BarIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bar/BarIndependentVanChartInterface.java @@ -1,5 +1,6 @@ package com.fr.van.chart.bar; +import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; import com.fr.design.condition.ConditionAttributesPane; @@ -10,7 +11,9 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.van.chart.column.VanChartColumnConditionPane; import com.fr.van.chart.column.VanChartColumnSeriesPane; +import com.fr.van.chart.designer.other.VanChartInteractivePane; import com.fr.van.chart.designer.other.VanChartOtherPane; +import com.fr.van.chart.designer.other.zoom.ZoomPane; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.vanchart.AbstractMultiCategoryVanChartUI; @@ -57,21 +60,37 @@ public class BarIndependentVanChartInterface extends AbstractMultiCategoryVanCha return new VanChartBarPlotPane(); } - public ConditionAttributesPane getPlotConditionPane(Plot plot){ + public ConditionAttributesPane getPlotConditionPane(Plot plot) { return new VanChartColumnConditionPane(plot); } - public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ + public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { return new VanChartColumnSeriesPane(parent, plot); } /** * 图表的属性界面数组 + * * @return 属性界面 */ - public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener){ + public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener) { VanChartStylePane stylePane = new VanChartBarStylePane(listener); - VanChartOtherPane otherPane = new VanChartOtherPane(); + VanChartOtherPane otherPane = new VanChartOtherPane() { + @Override + protected BasicBeanPane createInteractivePane() { + return new VanChartInteractivePane() { + @Override + protected ZoomPane createZoomPane() { + return new ZoomPane(); + } + + @Override + protected boolean isCurrentChartSupportLargeDataMode() { + return true; + } + }; + } + }; return new AbstractChartAttrPane[]{stylePane, otherPane}; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/BubbleIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/BubbleIndependentVanChartInterface.java index 8e732b406e..c648c09c73 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/BubbleIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/BubbleIndependentVanChartInterface.java @@ -3,6 +3,10 @@ package com.fr.van.chart.bubble; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chartx.AbstractVanSingleDataPane; +import com.fr.design.chartx.fields.diff.ScatterCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.ScatterDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -15,7 +19,9 @@ import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.plugin.chart.bubble.VanChartBubblePlot; import com.fr.van.chart.bubble.data.VanChartBubblePlotTableDataContentPane; +import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; +import com.fr.van.chart.designer.other.zoom.ZoomPane; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; @@ -63,22 +69,23 @@ public class BubbleIndependentVanChartInterface extends AbstractIndependentVanCh public String getIconPath() { return "com/fr/design/images/form/toolbar/bubble.png"; } + @Override - public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ + public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { return new VanChartBubbleSeriesPane(parent, plot); } @Override - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){ - if(((VanChartBubblePlot) plot).isForceBubble()){ + public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { + if (((VanChartBubblePlot) plot).isForceBubble()) { return super.getTableDataSourcePane(plot, parent); } return new VanChartBubblePlotTableDataContentPane(parent); } @Override - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent){ - if(((VanChartBubblePlot) plot).isForceBubble()){ + public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { + if (((VanChartBubblePlot) plot).isForceBubble()) { return super.getReportDataSourcePane(plot, parent); } return new BubblePlotReportDataContentPane(parent); @@ -86,19 +93,40 @@ public class BubbleIndependentVanChartInterface extends AbstractIndependentVanCh /** * 图表的属性界面数组 + * * @return 属性界面 */ - public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener){ + public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener) { VanChartStylePane stylePane = new VanChartBubbleStylePane(listener); - VanChartOtherPane otherPane = new VanChartOtherPane(){ + VanChartOtherPane otherPane = new VanChartOtherPane() { protected BasicBeanPane createInteractivePane() { - return new VanChartBubbleInteractivePane(); + return new VanChartInteractivePaneWithOutSort() { + @Override + protected ZoomPane createZoomPane() { + return new ZoomPane(); + } + + @Override + protected boolean isCurrentChartSupportLargeDataMode() { + return true; + } + }; } }; return new AbstractChartAttrPane[]{stylePane, otherPane}; } - public ConditionAttributesPane getPlotConditionPane(Plot plot){ + public ConditionAttributesPane getPlotConditionPane(Plot plot) { return new VanChartBubbleConditionPane(plot); } + + @Override + public ChartDataPane getChartDataPane(AttributeChangeListener listener) { + return new AbstractVanSingleDataPane(listener) { + @Override + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new ScatterDataSetFieldsPane(), new ScatterCellDataFieldsPane()); + } + }; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleInteractivePane.java deleted file mode 100644 index 7dad3847a0..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleInteractivePane.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.fr.van.chart.bubble; - -import com.fr.chart.chartattr.Plot; - -import com.fr.plugin.chart.base.VanChartConstants; -import com.fr.plugin.chart.bubble.VanChartBubblePlot; -import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; - -/** - * Created by Mitisky on 16/3/31. - */ -public class VanChartBubbleInteractivePane extends VanChartInteractivePaneWithOutSort { - protected String[] getNameArray() { - Plot plot = chart.getPlot(); - if(plot instanceof VanChartBubblePlot && ((VanChartBubblePlot) plot).isForceBubble()) { - return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}; - } - return super.getNameArray(); - } - - protected String[] getValueArray() { - Plot plot = chart.getPlot(); - if(plot instanceof VanChartBubblePlot && ((VanChartBubblePlot) plot).isForceBubble()) { - return new String[]{VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE}; - } - return super.getValueArray(); - } - -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java index d1f93a19e8..3e5bdd106b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java @@ -6,9 +6,9 @@ import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; +import com.fr.chartx.attr.ZoomAttribute; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.base.VanChartTools; -import com.fr.plugin.chart.base.VanChartZoom; import com.fr.plugin.chart.bubble.BubbleIndependentVanChart; import com.fr.plugin.chart.bubble.VanChartBubblePlot; import com.fr.plugin.chart.scatter.attr.ScatterAttrLabel; @@ -116,8 +116,7 @@ public class VanChartBubblePlotPane extends AbstractVanChartTypePane { */ @Override protected void resetChartAttr4SamePlot(Chart chart){ - VanChartZoom vanChartZoom = new VanChartZoom(); - ((VanChart)chart).setVanChartZoom(vanChartZoom); + ((VanChart) chart).setZoomAttribute(new ZoomAttribute()); //重置监控刷新选项 resetRefreshMoreLabelAttr((VanChart)chart); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java index 01c72649d6..b966cc6f98 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java @@ -6,8 +6,6 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; - -import com.fr.plugin.chart.bubble.VanChartBubblePlot; import com.fr.plugin.chart.bubble.attr.VanChartAttrBubble; import com.fr.van.chart.bubble.component.VanChartBubblePane; import com.fr.van.chart.custom.component.VanChartCustomAxisConditionPane; @@ -44,35 +42,31 @@ public class VanChartBubbleSeriesPane extends VanChartAbstractPlotSeriesPane { new Component[]{null} }; - if (!((VanChartBubblePlot)plot).isForceBubble()) { - components[3] = new Component[]{createLargeDataModelPane()}; - } - contentPane = TableLayoutHelper.createTableLayoutPane(components, row, col); return contentPane; } //设置色彩面板内容 @Override - protected void setColorPaneContent (JPanel panel) { + protected void setColorPaneContent(JPanel panel) { panel.add(createAlphaPane(), BorderLayout.CENTER); } @Override //堆积和坐标轴设置(自定义柱形图等用到) protected JPanel createStackedAndAxisPane() { - stackAndAxisEditPane = new VanChartStackedAndAxisListControlPane(){ + stackAndAxisEditPane = new VanChartStackedAndAxisListControlPane() { @Override protected Class getStackAndAxisPaneClass() { return VanChartCustomAxisConditionPane.class; } @Override - public String getPaneTitle(){ + public String getPaneTitle() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Axis"); } }; - stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); + stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); return stackAndAxisEditExpandablePane; } @@ -81,18 +75,18 @@ public class VanChartBubbleSeriesPane extends VanChartAbstractPlotSeriesPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Bubble"), bubblePane); } - protected void populateCondition(ConditionAttr defaultAttr){ - super.populateCondition(defaultAttr); - if(bubblePane != null) { - VanChartAttrBubble attrBubble = (VanChartAttrBubble) defaultAttr.getExisted(VanChartAttrBubble.class); + protected void populateCondition(ConditionAttr defaultAttr) { + super.populateCondition(defaultAttr); + if (bubblePane != null) { + VanChartAttrBubble attrBubble = defaultAttr.getExisted(VanChartAttrBubble.class); bubblePane.populateBean(attrBubble); } } - protected void updateCondition(ConditionAttr defaultAttr){ + protected void updateCondition(ConditionAttr defaultAttr) { super.updateCondition(defaultAttr); - if(bubblePane != null){ - VanChartAttrBubble attrBubble = (VanChartAttrBubble) defaultAttr.getExisted(VanChartAttrBubble.class); + if (bubblePane != null) { + VanChartAttrBubble attrBubble = defaultAttr.getExisted(VanChartAttrBubble.class); if (attrBubble != null) { defaultAttr.remove(attrBubble); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanColumnChartTypeUI.java similarity index 80% rename from designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java rename to designer-chart/src/main/java/com/fr/van/chart/column/VanColumnChartTypeUI.java index ebecf18caa..0d491f9046 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanColumnChartTypeUI.java @@ -11,7 +11,7 @@ import com.fr.van.chart.vanchart.AbstractMultiCategoryVanChartUI; /** * Created by Mitisky on 15/9/24. */ -public class ColumnIndependentVanChartInterface extends AbstractMultiCategoryVanChartUI { +public class VanColumnChartTypeUI extends AbstractMultiCategoryVanChartUI { @Override public String getName() { @@ -60,13 +60,4 @@ public class ColumnIndependentVanChartInterface extends AbstractMultiCategoryVan return new VanChartColumnSeriesPane(parent, plot); } -// @Override -// public ChartDataPane getChartDataPane(AttributeChangeListener listener) { -// return new AbstractDataPane(listener) { -// @Override -// protected SingleDataPane createSingleDataPane() { -// return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane()); -// } -// }; -// } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java index 927fa31485..70431b2e79 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java @@ -6,6 +6,8 @@ import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.chartx.data.CustomChartDataDefinition; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.type.ChartImagePane; @@ -24,11 +26,11 @@ import com.fr.van.chart.designer.type.AbstractVanChartTypePane; import javax.swing.JPanel; import javax.swing.JSeparator; +import java.util.HashMap; +import java.util.Map; import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; -import java.util.HashMap; -import java.util.Map; /** * Created by Mitisky on 16/2/16. @@ -123,6 +125,7 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { //如果上次的状态和这次的装填不在同一个页面,说明同一个图表內切换了,需要情況数据配置 if (lastState != chart.getPlot().getDetailType()) { chart.setFilterDefinition(null); + ((VanChart) chart).setChartDataDefinition(null); } Chart[] customChart = CustomIndependentVanChart.CustomVanChartTypes; @@ -137,6 +140,9 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { dealCustomDefinition(chart); customSelectPane.updateBean(chart); + + //更新新的数据配置 + dealCustomChartDataDefinition(chart); } else if (isSamePlot()) {//如果是同一个图表切换过来,则重置面板 customSelectPane.populateBean(chart); } @@ -150,6 +156,27 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { } + private void dealCustomChartDataDefinition(Chart chart) { + CustomChartDataDefinition chartDataDefinition = (CustomChartDataDefinition) ((VanChart) chart).getChartDataDefinition(); + + if (chartDataDefinition == null) { + return; + } + + Map customDefinitions = chartDataDefinition.getCustomDefinitions(); + + Map newCustomDefinitions = new HashMap<>(); + + VanChartCustomPlot customPlot = chart.getPlot(); + for (int i = 0; i < customPlot.getCustomPlotList().size(); i++) { + CustomPlotType plotType = CustomPlotFactory.getCustomType(customPlot.getCustomPlotList().get(i)); + AbstractDataDefinition definition = customDefinitions.get(plotType); + newCustomDefinitions.put(plotType, definition); + } + + chartDataDefinition.setCustomDefinitions(newCustomDefinitions); + } + private void dealCustomDefinition(Chart chart) { CustomDefinition definition = (CustomDefinition) chart.getFilterDefinition(); @@ -229,9 +256,9 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { } Plot cloned = null; try { - if(newPlot != null) { - cloned = (Plot) newPlot.clone(); - } + if (newPlot != null) { + cloned = (Plot) newPlot.clone(); + } } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error("Error In ScatterChart"); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java index 7c46b8b085..15598f3181 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java @@ -7,7 +7,6 @@ import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.style.FormatPane; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; - import com.fr.plugin.chart.area.VanChartAreaPlot; import com.fr.plugin.chart.bubble.VanChartBubblePlot; import com.fr.plugin.chart.column.VanChartColumnPlot; @@ -86,14 +85,15 @@ public class PlotFactory { autoAdjustLabelPlots.add(VanChartStructurePlot.class); } - public static boolean plotAutoAdjustLabelPosition(Plot plot){ + public static boolean plotAutoAdjustLabelPosition(Plot plot) { return autoAdjustLabelPlots.contains(plot.getClass()); } + /** - * * 标签Map */ private static Map, Class> labelMap = new HashMap, Class>(); + static { labelMap.put(VanChartGaugePlot.class, VanChartGaugePlotLabelPane.class); labelMap.put(VanChartScatterPlot.class, VanChartScatterPlotLabelPane.class); @@ -104,6 +104,7 @@ public class PlotFactory { * 图例Map */ private static Map, Class> legendMap = new HashMap, Class>(); + static { legendMap.put(VanChartGaugePlot.class, VanLegendPaneWidthOutHighlight.class); legendMap.put(VanChartMultiPiePlot.class, VanLegendPaneWidthOutHighlight.class); @@ -119,6 +120,7 @@ public class PlotFactory { * 数据点提示Map */ private static Map, Class> toolTipMap = new HashMap, Class>(); + static { toolTipMap.put(VanChartGaugePlot.class, VanChartGaugePlotTooltipPane.class); toolTipMap.put(VanChartScatterPlot.class, VanChartScatterPlotTooltipPane.class); @@ -156,18 +158,19 @@ public class PlotFactory { } - /** * 监控刷新 自动数据点提示Map */ private static Map, Class> refreshToolTipMap = new HashMap, Class>(); + static { refreshToolTipMap.put(VanChartGaugePlot.class, VanChartGaugePlotRefreshTooltipPane.class); refreshToolTipMap.put(VanChartBubblePlot.class, VanChartBubbleRefreshTooltipPane.class); } + private static Map, Class> refreshTooltipContentMap = new HashMap, Class>(); static { @@ -186,18 +189,19 @@ public class PlotFactory { /** * 根据图表类型创建标签界面 - * @param plot 图表 + * + * @param plot 图表 * @param stylePane 样式界面 * @return 标签界面 */ public static VanChartPlotLabelPane createPlotLabelPane(Plot plot, VanChartStylePane stylePane) { Class key = plot.getClass(); - if(labelMap.containsKey(key)){ - try{ + if (labelMap.containsKey(key)) { + try { Class cl = labelMap.get(key); - Constructor constructor = cl.getConstructor(Plot.class, VanChartStylePane.class); + Constructor constructor = cl.getConstructor(Plot.class, VanChartStylePane.class); return constructor.newInstance(plot, stylePane); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -206,18 +210,19 @@ public class PlotFactory { /** * 根据图表类型创建图例界面 - * @param plot 图表 + * + * @param plot 图表 * @param stylePane 样式界面 * @return 图例界面 */ public static VanChartPlotLegendPane createPlotLegendPane(Plot plot, VanChartStylePane stylePane) { Class key = plot.getClass(); - if(legendMap.containsKey(key)){ - try{ + if (legendMap.containsKey(key)) { + try { Class cl = legendMap.get(key); - Constructor constructor = cl.getConstructor(VanChartStylePane.class); + Constructor constructor = cl.getConstructor(VanChartStylePane.class); return constructor.newInstance(stylePane); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -226,18 +231,19 @@ public class PlotFactory { /** * 根据图表类型创建数据点提示界面 - * @param plot 图表 + * + * @param plot 图表 * @param stylePane 样式界面 * @return 数据点提示界面 */ - public static VanChartPlotTooltipPane createPlotTooltipPane(Plot plot, VanChartStylePane stylePane) { + public static VanChartPlotTooltipPane createPlotTooltipPane(Plot plot, VanChartStylePane stylePane) { Class key = plot.getClass(); - if(toolTipMap.containsKey(key)){ - try{ + if (toolTipMap.containsKey(key)) { + try { Class cl = toolTipMap.get(key); - Constructor constructor = cl.getConstructor(Plot.class, VanChartStylePane.class); + Constructor constructor = cl.getConstructor(Plot.class, VanChartStylePane.class); return constructor.newInstance(plot, stylePane); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -246,19 +252,20 @@ public class PlotFactory { /** * 根据图表类型创建标签的具体内容界面.分类名系列名等 - * @param plot 图表 - * @param parent 样式界面 + * + * @param plot 图表 + * @param parent 样式界面 * @param showOnPane formatpane用到 * @return 标签的具体内容界面 */ - public static VanChartTooltipContentPane createPlotLabelContentPane(Plot plot, VanChartStylePane parent, JPanel showOnPane){ + public static VanChartTooltipContentPane createPlotLabelContentPane(Plot plot, VanChartStylePane parent, JPanel showOnPane) { Class key = plot.getClass(); - if(labelContentMap.containsKey(key)){ - try{ + if (labelContentMap.containsKey(key)) { + try { Class cl = labelContentMap.get(key); - Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); + Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); return constructor.newInstance(parent, showOnPane); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -267,19 +274,20 @@ public class PlotFactory { /** * 根据图表类型创建数据点提示的具体内容界面.分类名系列名等 - * @param plot 图表 - * @param parent 样式界面 + * + * @param plot 图表 + * @param parent 样式界面 * @param showOnPane formatpane用到 * @return 数据点提示的具体内容界面 */ - public static VanChartTooltipContentPane createPlotTooltipContentPane(Plot plot, VanChartStylePane parent, JPanel showOnPane){ + public static VanChartTooltipContentPane createPlotTooltipContentPane(Plot plot, VanChartStylePane parent, JPanel showOnPane) { Class key = plot.getClass(); - if(tooltipContentMap.containsKey(key)){ - try{ + if (tooltipContentMap.containsKey(key)) { + try { Class cl = tooltipContentMap.get(key); - Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); + Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); return constructor.newInstance(parent, showOnPane); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -287,56 +295,59 @@ public class PlotFactory { } - /** * 根据图表类型创建数据点提示界面 + * * @param plot 图表 * @return 数据点提示界面 */ public static VanChartPlotTooltipPane createPlotRefreshTooltipPane(Plot plot) { Class key = plot.getClass(); - if(refreshToolTipMap.containsKey(key)){ - try{ + if (refreshToolTipMap.containsKey(key)) { + try { Class cl = refreshToolTipMap.get(key); - Constructor constructor = cl.getConstructor(Plot.class); + Constructor constructor = cl.getConstructor(Plot.class); return constructor.newInstance(plot); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return new VanChartPlotRefreshTooltipPane(plot); } + /** * 根据图表类型创建监控刷新中数据点提示的具体内容界面.分类名系列名等 - * @param plot 图表 - * @param parent 交互属性界面 + * + * @param plot 图表 + * @param parent 交互属性界面 * @param showOnPane formatpane用到 * @return 数据点提示的具体内容界面 */ - public static VanChartTooltipContentPane createPlotRefreshTooltipContentPane(Plot plot, VanChartStylePane parent, JPanel showOnPane){ + public static VanChartTooltipContentPane createPlotRefreshTooltipContentPane(Plot plot, VanChartStylePane parent, JPanel showOnPane) { Class key = plot.getClass(); - if(refreshTooltipContentMap.containsKey(key)){ - try{ + if (refreshTooltipContentMap.containsKey(key)) { + try { Class cl = refreshTooltipContentMap.get(key); - Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); + Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); return constructor.newInstance(parent, showOnPane); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return new VanChartRefreshTooltipContentPane(parent, showOnPane); } - public static FormatPane createAutoFormatPane(){ - FormatPane formatPane = new FormatPane(){ - protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane) { + public static FormatPane createAutoFormatPane() { + FormatPane formatPane = new FormatPane() { + protected Component[][] getComponent(JPanel fontPane, JPanel centerPane, JPanel typePane) { typePane.setBorder(BorderFactory.createEmptyBorder()); return new Component[][]{ - new Component[]{typePane,null}, + new Component[]{typePane, null}, new Component[]{centerPane, null}, }; } - protected UIComboBoxRenderer createComBoxRender(){ + + protected UIComboBoxRenderer createComBoxRender() { return new UIComboBoxRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @@ -361,12 +372,8 @@ public class PlotFactory { /** * 判断是否为大数据模式 */ - public static boolean largeDataModel(Plot plot){ - return plot != null && plot.getDataProcessor().getMark() == LargeDataModel.MARK; - } - - public static boolean lineMapLargeModel(Plot plot){ - return plot instanceof VanChartMapPlot && ((VanChartMapPlot) plot).getLineMapDataProcessor().getMark() == LargeDataModel.MARK; + public static boolean largeDataModel(Plot plot) { + return plot != null && plot.convertDataProcessor().getMark() == LargeDataModel.MARK; } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java new file mode 100644 index 0000000000..0b3bc7571a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java @@ -0,0 +1,85 @@ +package com.fr.van.chart.designer.component; + +import com.fr.base.FRContext; +import com.fr.base.GraphHelper; +import com.fr.base.ScreenResolution; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icombobox.UIComboBoxRenderer; +import com.fr.design.i18n.Toolkit; +import com.fr.general.FRFont; +import com.fr.plugin.chart.type.LineType; +import com.fr.stable.Constants; + +import javax.swing.JLabel; +import javax.swing.JList; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; + +/** + * Created by shine on 2019/08/30. + */ +public class LineTypeComboBox extends UIComboBox { + + public LineTypeComboBox(LineType[] lineType) { + super(lineType); + + this.setRenderer(new CellRenderer()); + } + + private static class CellRenderer extends UIComboBoxRenderer { + + private LineType lineType; + + public Component getListCellRendererComponent( + JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + + JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + this.lineType = (LineType) value; + comp.setText(null); + return comp; + } + + public void paint(Graphics g) { + super.paint(g); + Graphics2D g2d = (Graphics2D) g; + + Dimension d = getSize(); + g2d.setColor(getForeground()); + + switch (this.lineType) { + case NONE: + FRFont font = FRContext.getDefaultValues().getFRFont(); + int resolution = ScreenResolution.getScreenResolution(); + Font rfont = font.applyResolutionNP(resolution); + g2d.setFont(rfont); + FontMetrics fm = GraphHelper.getFontMetrics(rfont); + GraphHelper.drawString(g2d, Toolkit.i18nText("Fine-Design_Report_None"), 4, (d.height - fm.getHeight()) / 2 + fm.getAscent()); + break; + case NORMAL: + GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2); + break; + case DASH: + GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2, Constants.LINE_DASH); + break; + default: + break; + + } + } + + public Dimension getPreferredSize() { + return new Dimension(60, 16); + } + + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + } + + +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java index 78f93162f8..8f885d2e87 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java @@ -2,21 +2,24 @@ package com.fr.van.chart.designer.component; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; - import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; +import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.base.VanChartAttrLine; import com.fr.plugin.chart.type.LineStyle; -import com.fr.stable.Constants; -import com.fr.stable.CoreConstants; +import com.fr.plugin.chart.type.LineType; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; /** * line相关设置 @@ -24,64 +27,122 @@ import java.awt.Component; public class VanChartLineTypePane extends BasicPane { private static final long serialVersionUID = -6581862503009962973L; - protected LineComboBox lineWidth;//线型 + private LineTypeComboBox lineTypeComboBox;//线型 + private UISpinner lineWidthSpinner;//线宽 protected UIButtonGroup lineStyle;//形态 - protected UIButtonGroup nullValueBreak;//空值断开 + private UIButtonGroup nullValueBreak;//空值断开 + + private JPanel lineWidthPane; + private JPanel lineStylePane; public VanChartLineTypePane() { - lineWidth = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); + + JPanel typeAndWidthPane = createTypeAndWidthPane(); createLineStyle(); - nullValueBreak = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}); + nullValueBreak = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open"), Toolkit.i18nText("Fine-Design_Chart_Close")}); - this.setLayout(new BorderLayout()); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - this.add(createContentPane(p, f), BorderLayout.CENTER); + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + + Component[] lineStyleComponent = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Style_Present")), lineStyle}, + nullValueBreakComponent = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Null_Value_Break")), nullValueBreak}; + + Component[][] components = createContentComponent(lineStyleComponent, nullValueBreakComponent); + + double[] row = new double[components.length]; + Arrays.fill(row, p); + double[] col = {f, e}; + + lineStylePane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + + this.setLayout(new BorderLayout(0, 6)); + this.add(typeAndWidthPane, BorderLayout.NORTH); + this.add(lineStylePane, BorderLayout.CENTER); + } + + private JPanel createTypeAndWidthPane() { + + lineTypeComboBox = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.NORMAL, LineType.DASH}); + + lineWidthSpinner = new UISpinner(0.5, Integer.MAX_VALUE, 0.5, 2); + + lineTypeComboBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkLineWidth(); + checkLineStyle(); + } + }); + + Component[][] lineTypeComps = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineTypeComboBox} + }; + Component[][] lineWidthComps = new Component[][]{ + new Component[]{ + FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Width")), + UIComponentUtils.wrapWithBorderLayoutPane(lineWidthSpinner)} + }; + + double p = TableLayout.PREFERRED, f = TableLayout.FILL, e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] row = {p}, col = {f, e}; + + JPanel lineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(lineTypeComps, row, col); + lineWidthPane = TableLayout4VanChartHelper.createGapTableLayoutPane(lineWidthComps, row, col); + + JPanel contentPane = new JPanel(new BorderLayout(0, 6)); + + contentPane.add(lineTypePane, BorderLayout.CENTER); + contentPane.add(lineWidthPane, BorderLayout.SOUTH); + + return contentPane; } protected void createLineStyle() { - String[] textArray = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Normal_Line"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_StepLine"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_CurveLine")}; + String[] textArray = new String[]{Toolkit.i18nText("Fine-Design_Chart_Normal_Line"), + Toolkit.i18nText("Fine-Design_Chart_StepLine"), Toolkit.i18nText("Fine-Design_Chart_CurveLine")}; lineStyle = new UIButtonGroup(textArray, LineStyle.values()); } - protected JPanel createContentPane(double p, double f) { - double[] row = {p, p, p, p}; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] col = {f, e}; - - Component[][] components = new Component[][]{ - new Component[]{null,null}, - new Component[]{ - FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), - UIComponentUtils.wrapWithBorderLayoutPane(lineWidth) - }, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Present")),lineStyle}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Break")),nullValueBreak}, + protected Component[][] createContentComponent(Component[] lineStyleComponent, Component[] nullValueBreakComponent) { + return new Component[][]{ + lineStyleComponent, + nullValueBreakComponent }; + } - return TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + private void checkLineWidth() { + if (lineWidthPane != null && lineTypeComboBox != null) { + lineWidthPane.setVisible(!ComparatorUtils.equals(lineTypeComboBox.getSelectedItem(), LineType.NONE)); + } + } + + private void checkLineStyle() { + if (lineStylePane != null && lineTypeComboBox != null) { + lineStylePane.setVisible(!ComparatorUtils.equals(lineTypeComboBox.getSelectedItem(),LineType.NONE)); + } } - public void checkLarge(boolean large){ - if(large){ - lineWidth.setSelectedLineStyle(Constants.LINE_NONE); + public void checkLarge(boolean large) { + if (large) { + lineTypeComboBox.setSelectedItem(LineType.NONE); } - lineWidth.setEnabled(!large); + lineTypeComboBox.setEnabled(!large); lineStyle.setEnabled(!large); } protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line"); + return Toolkit.i18nText("Fine-Design_Chart_Line"); } public void populate(VanChartAttrLine line) { if (line == null) { line = initVanChartAttrLine(); } - lineWidth.setSelectedLineStyle(line.getLineWidth()); + lineTypeComboBox.setSelectedItem(line.getLineType()); + lineWidthSpinner.setValue(line.getLineWidth()); lineStyle.setSelectedItem(line.getLineStyle()); nullValueBreak.setSelectedIndex(line.isNullValueBreak() ? 0 : 1); } @@ -92,7 +153,8 @@ public class VanChartLineTypePane extends BasicPane { public VanChartAttrLine update() { VanChartAttrLine line = new VanChartAttrLine(); - line.setLineWidth(lineWidth.getSelectedLineStyle()); + line.setLineType((LineType) lineTypeComboBox.getSelectedItem()); + line.setLineWidth(lineWidthSpinner.getValue()); line.setLineStyle(lineStyle.getSelectedItem()); line.setNullValueBreak(nullValueBreak.getSelectedIndex() == 0); return line; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineWidthPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineWidthPane.java index 72ee1666ae..48f622654e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineWidthPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineWidthPane.java @@ -1,30 +1,17 @@ package com.fr.van.chart.designer.component; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.TableLayoutHelper; - -import com.fr.van.chart.designer.TableLayout4VanChartHelper; - -import javax.swing.JPanel; import java.awt.Component; /** - * 线-线型 + * 线型+线宽+空值断开 */ public class VanChartLineWidthPane extends VanChartLineTypePane { private static final long serialVersionUID = 4537158946119294689L; - protected JPanel createContentPane(double p, double f) { - double[] row = {p, p, p}; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] col = {f, e}; - - Component[][] components = new Component[][]{ - new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineWidth}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Break")), nullValueBreak}, + @Override + protected Component[][] createContentComponent(Component[] lineStyleComponent, Component[] nullValueBreakComponent) { + return new Component[][]{ + nullValueBreakComponent }; - - return TableLayoutHelper.createTableLayoutPane(components, row, col); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java index 134598bd71..e07738a9ae 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java @@ -1,29 +1,29 @@ package com.fr.van.chart.designer.component; import com.fr.chart.base.AttrColor; -import com.fr.chart.base.AttrLineStyle; import com.fr.chart.base.LineStyleInfo; import com.fr.design.dialog.BasicPane; -import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.style.color.ColorSelectBox; - import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.base.TrendLineType; import com.fr.plugin.chart.base.VanChartAttrTrendLine; -import com.fr.plugin.chart.base.VanChartConstants; +import com.fr.plugin.chart.type.LineType; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.JPanel; import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * Created by Mitisky on 15/10/19. @@ -33,62 +33,90 @@ public class VanChartTrendLinePane extends BasicPane{ private UITextField trendLineName; private ColorSelectBox trendLineColor; - private LineComboBox trendLineStyle;//线型 + private LineTypeComboBox trendLineStyle;//线型 + private UISpinner lineWidthSpinner;//线宽 private UIComboBox trendLineType;//趋势线函数类型 private UISpinner prePeriod; private UISpinner afterPeriod; + private JPanel trendLineHidePane; + public VanChartTrendLinePane() { - this.setLayout(new BorderLayout()); + initComponents(); + } + + private void initComponents(){ + this.setLayout(new BorderLayout(0,6)); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] row = {p,p,p,p,p,p}; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] col = {f, e}; trendLineName = new UITextField(); trendLineColor = new ColorSelectBox(100); - trendLineStyle = new LineComboBox(VanChartConstants.ALERT_LINE_STYLE); - + trendLineStyle = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.NORMAL, LineType.DASH}); + lineWidthSpinner = new UISpinner(0.5, Integer.MAX_VALUE, 0.5, 2); trendLineType = new UIComboBox(TYPES); prePeriod = new UISpinner(0, Integer.MAX_VALUE, 1, 0); afterPeriod = new UISpinner(0, Integer.MAX_VALUE, 1, 0); + double[] r = {p, p}; double[] c = {f, p, f, p}; Component[][] periodComps = new Component[][]{ - new Component[]{prePeriod, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Cycle")), afterPeriod, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Cycle"))}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TrendLine_Forward")), null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_After_Period")), null}, + new Component[]{prePeriod, new UILabel(Toolkit.i18nText("Fine-Design_Chart_Cycle")), afterPeriod, new UILabel(Toolkit.i18nText("Fine-Design_Chart_Cycle"))}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_TrendLine_Forward")), null, new UILabel(Toolkit.i18nText("Fine-Design_Chart_After_Period")), null}, }; JPanel periodPane = TableLayoutHelper.createTableLayoutPane(periodComps, r, c); - UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Period")); + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Period")); label.setVerticalAlignment(SwingConstants.TOP); Component[][] components = new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Name")), trendLineName}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Name")), trendLineName}, + new Component[]{ + FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), + UIComponentUtils.wrapWithBorderLayoutPane(trendLineStyle) + } + }; + + Component[][] componentsMayHide = new Component[][]{ new Component[]{ - FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), - UIComponentUtils.wrapWithBorderLayoutPane(trendLineStyle) - }, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")), trendLineColor}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type")), trendLineType}, + FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Width")), + UIComponentUtils.wrapWithBorderLayoutPane(lineWidthSpinner)}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), trendLineColor}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), trendLineType}, new Component[]{label, periodPane} }; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p,p,p}, col); + trendLineHidePane = TableLayout4VanChartHelper.createGapTableLayoutPane(componentsMayHide, new double[]{p,p,p,p}, col); + + trendLineStyle.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkHidePaneVisible(); + } + }); + + checkHidePaneVisible(); + this.add(panel, BorderLayout.CENTER); + this.add(trendLineHidePane, BorderLayout.SOUTH); } + protected String title4PopupWindow(){ - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TrendLine"); + return Toolkit.i18nText("Fine-Design_Chart_TrendLine"); } public void populate(VanChartAttrTrendLine trendLine) { + checkHidePaneVisible(); if(trendLine != null){ trendLineName.setText(trendLine.getTrendLineName()); LineStyleInfo lineStyleInfo = trendLine.getLineStyleInfo(); trendLineColor.setSelectObject(lineStyleInfo.getAttrLineColor().getSeriesColor()); - trendLineStyle.setSelectedLineStyle(lineStyleInfo.getAttrLineStyle().getLineStyle()); + trendLineStyle.setSelectedItem(lineStyleInfo.getAttrLineStyle().getLineType()); + lineWidthSpinner.setValue(lineStyleInfo.getAttrLineStyle().getLineWidth()); trendLineType.setSelectedItem(trendLine.getTrendLineType()); prePeriod.setValue(trendLine.getPrePeriod()); afterPeriod.setValue(trendLine.getAfterPeriod()); @@ -100,7 +128,8 @@ public class VanChartTrendLinePane extends BasicPane{ trendLine.setTrendLineName(trendLineName.getText()); LineStyleInfo lineStyleInfo = trendLine.getLineStyleInfo(); - lineStyleInfo.setAttrLineStyle(new AttrLineStyle(trendLineStyle.getSelectedLineStyle())); + lineStyleInfo.getAttrLineStyle().setLineWidth(lineWidthSpinner.getValue()); + lineStyleInfo.getAttrLineStyle().setLineType((LineType) trendLineStyle.getSelectedItem()); lineStyleInfo.setAttrLineColor(new AttrColor(trendLineColor.getSelectObject())); trendLine.setTrendLineType((TrendLineType) trendLineType.getSelectedItem()); @@ -110,4 +139,10 @@ public class VanChartTrendLinePane extends BasicPane{ return trendLine; } + private void checkHidePaneVisible(){ + if (trendLineHidePane != null && trendLineStyle != null){ + trendLineHidePane.setVisible(trendLineStyle.getSelectedItem() != LineType.NONE); + } + } + } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java index 664b3d8cf6..ba4d944d47 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java @@ -1,36 +1,39 @@ package com.fr.van.chart.designer.other; -import com.fr.base.BaseFormula; -import com.fr.base.Utils; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; -import com.fr.design.formula.TinyFormulaPane; +import com.fr.chart.chartglyph.ConditionAttr; +import com.fr.chart.chartglyph.ConditionCollection; +import com.fr.chartx.attr.LargeDataAttribute; +import com.fr.chartx.attr.LargeDataModeType; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; - import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; import com.fr.plugin.chart.axis.type.AxisPlotType; +import com.fr.plugin.chart.base.AttrEffect; +import com.fr.plugin.chart.base.AttrLabel; import com.fr.plugin.chart.base.RefreshMoreLabel; -import com.fr.plugin.chart.base.VanChartConstants; +import com.fr.plugin.chart.base.VanChartAttrMarker; import com.fr.plugin.chart.base.VanChartTools; -import com.fr.plugin.chart.base.VanChartZoom; +import com.fr.plugin.chart.map.line.condition.AttrLineEffect; +import com.fr.plugin.chart.scatter.attr.ScatterAttrLabel; import com.fr.plugin.chart.vanchart.VanChart; -import com.fr.stable.StableUtils; import com.fr.van.chart.custom.component.VanChartHyperLinkPane; import com.fr.van.chart.designer.AbstractVanChartScrollPane; import com.fr.van.chart.designer.PlotFactory; import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.other.zoom.ZoomPane; -import javax.swing.BorderFactory; import javax.swing.JPanel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.ActionEvent; @@ -46,6 +49,10 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { protected UICheckBox fullScreenDisplay; protected UIToggleButton collapse; + protected VanChart chart; + private UIComboBox largeDataMode; + private UISpinner largeModeThresholdNumber; + protected UIButtonGroup isChartAnimation; //坐标轴翻转属性 @@ -53,22 +60,15 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { private AutoRefreshPane autoRefreshPane; - private UIButtonGroup zoomWidget; - protected UIButtonGroup zoomGesture;//地图手势缩放 - private UIButtonGroup zoomResize; - private TinyFormulaPane from; - private TinyFormulaPane to; - private UIButtonGroup zoomType; - private JPanel changeEnablePane; - private JPanel zoomTypePane; + private ZoomPane zoomPane; protected VanChartHyperLinkPane superLink; - - protected Chart chart; + private JPanel largeModeThresholdNumberPane; protected JPanel interactivePane; /** * 界面标题. + * * @return 返回标题. */ @@ -82,7 +82,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { return new JPanel(); } - private void reLayoutContentPane(VanChartPlot plot){ + private void reLayoutContentPane(VanChartPlot plot) { if (interactivePane != null) { interactivePane.removeAll(); } @@ -90,121 +90,93 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { reloaPane(interactivePane); } - protected JPanel getInteractivePane(VanChartPlot plot){ + protected JPanel getInteractivePane(VanChartPlot plot) { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f, e}; - double[] rowSize = {p,p,p,p,p,p}; + double[] rowSize = {p, p, p, p, p, p, p}; Component[][] components = new Component[][]{ - new Component[]{createToolBarPane(getToolBarRowSize(), columnSize),null}, - new Component[]{createAnimationPane(),null}, - new Component[]{createAxisRotationPane(new double[]{p,p}, columnSize, plot),null}, - new Component[]{createZoomPane(new double[]{p,p,p}, columnSize, plot),null}, - new Component[]{createAutoRefreshPane(plot),null}, - new Component[]{createHyperlinkPane(),null} + new Component[]{createToolBarPane(getToolBarRowSize(), columnSize), null}, + new Component[]{createLargeDataModePane(), null}, + new Component[]{createAnimationPane(), null}, + new Component[]{createAxisRotationPane(new double[]{p, p}, columnSize, plot), null}, + new Component[]{createZoomPane(new double[]{p, p, p}, columnSize, plot), null}, + new Component[]{createAutoRefreshPane(plot), null}, + new Component[]{createHyperlinkPane(), null} }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } - protected JPanel createZoomPane(double[] row, double[] col, VanChartPlot plot) { - if (!plot.isSupportZoomDirection()) { + private JPanel createLargeDataModePane() { + if (!isCurrentChartSupportLargeDataMode()) { return null; } - zoomWidget = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}); - zoomResize = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Change"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Non_Adjustment")}); - from = new TinyFormulaPane(); - to = new TinyFormulaPane(); - zoomType = new UIButtonGroup(getNameArray(), getValueArray()); - zoomGesture = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}); - - JPanel zoomWidgetPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Zoom_Widget"), zoomWidget); - JPanel zoomGesturePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_ZoomGesture"), zoomGesture); - - Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Boundary")), zoomResize}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_From")), from}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_To")), to}, - }; + largeDataMode = new UIComboBox(new LargeDataModeType[]{LargeDataModeType.CLOSE, LargeDataModeType.OPEN_BEYOND_THRESHOLD}); + largeModeThresholdNumber = new UISpinner(0, Integer.MAX_VALUE, 100, chart.getPlot().getLargeDataAttribute().getLargeModeThresholdNumber()); - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; - double[] columnSize = {f, e}; - changeEnablePane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, columnSize); - changeEnablePane.setBorder(BorderFactory.createEmptyBorder(10,12,0,0)); - zoomTypePane = getzoomTypePane(zoomType); - JPanel panel = createZoomPaneContent(zoomWidgetPane, zoomGesturePane, changeEnablePane, zoomTypePane, plot); - zoomWidget.addActionListener(new ActionListener() { + largeDataMode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - checkZoomPane(); + checkLargeDataMode(); } }); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Zoom"), panel); - } + + Component[][] comps1 = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Large_Model")), largeDataMode} + }; + Component[][] comps2 = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Threshold_Number")), largeModeThresholdNumber} + }; + + double[] row = {TableLayout.PREFERRED}, col = {TableLayout.FILL, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; - protected JPanel getzoomTypePane(UIButtonGroup zoomType) { - return TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Zoom_Direction"), zoomType); + JPanel contentPane = new JPanel(new BorderLayout(0, 6)); + + contentPane.add(TableLayout4VanChartHelper.createGapTableLayoutPane(comps1, row, col), BorderLayout.CENTER); + largeModeThresholdNumberPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps2, row, col); + contentPane.add(largeModeThresholdNumberPane, BorderLayout.SOUTH); + + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Large_Data"), contentPane); + } + + protected boolean isCurrentChartSupportLargeDataMode() { + return false; } - protected JPanel createZoomPaneContent(JPanel zoomWidgetPane, JPanel zoomGesturePane, JPanel changeEnablePane, JPanel zoomTypePane, VanChartPlot plot) { - JPanel panel = new JPanel(new BorderLayout(0, 4)); - if (plot.isSupportZoomCategoryAxis()) {//支持缩放控件 - panel.add(zoomWidgetPane, BorderLayout.NORTH); - panel.add(changeEnablePane, BorderLayout.CENTER); + protected JPanel createZoomPane(double[] row, double[] col, VanChartPlot plot) { + zoomPane = createZoomPane(); + if (zoomPane == null) { + return null; } - panel.add(zoomTypePane, BorderLayout.SOUTH); - return panel; + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Zoom"), zoomPane); + } + + protected ZoomPane createZoomPane() { + return null; } - private JPanel createAxisRotationPane(double[] row, double[] col, VanChartPlot plot){ - if (!(plot.getAxisPlotType() == AxisPlotType.RECTANGLE)){ + private JPanel createAxisRotationPane(double[] row, double[] col, VanChartPlot plot) { + if (!(plot.getAxisPlotType() == AxisPlotType.RECTANGLE)) { return null; } axisRotation = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}); - axisRotation.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - checkZoomEnabled(); - } - }); + Component[][] components = new Component[][]{ - new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Reversal")),axisRotation} + new Component[]{null, null}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Reversal")), axisRotation} }; JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis"), panel); } - private void checkZoomEnabled() { - if (zoomWidget != null && axisRotation != null) { - if (axisRotation.getSelectedIndex() == 0) { - //只有开启坐标轴翻转,才需要将缩放控件强制关闭。 - zoomWidget.setSelectedIndex(1); - } - checkZoomPane(); - zoomWidget.setEnabled(axisRotation.getSelectedIndex() == 1); - } - } - - - protected String[] getNameArray() { - return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_X_Axis"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Y_Axis") - ,com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}; - } - - protected String[] getValueArray() { - return new String[]{VanChartConstants.ZOOM_TYPE_X, VanChartConstants.ZOOM_TYPE_Y - ,VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE}; - } - - protected JPanel createToolBarPane(double[] row, double[] col){ + protected JPanel createToolBarPane(double[] row, double[] col) { isSort = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Sort")); exportImages = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Export_Image")); fullScreenDisplay = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_FullScreen_Display")); @@ -216,17 +188,17 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_ToolBar"), panel); } - protected double[] getToolBarRowSize () { + protected double[] getToolBarRowSize() { double p = TableLayout.PREFERRED; - return new double[]{p,p,p,p,p}; + return new double[]{p, p, p, p, p}; } protected Component[][] createToolBarComponents() { return new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")),isSort}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")), isSort}, new Component[]{null, exportImages}, new Component[]{null, fullScreenDisplay}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout")),collapse}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout")), collapse}, }; } @@ -234,18 +206,18 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { return new Component[][]{ new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")), exportImages}, new Component[]{null, fullScreenDisplay}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout")),collapse} + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout")), collapse} }; } - protected JPanel createAnimationPane(){ + protected JPanel createAnimationPane() { isChartAnimation = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}); JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Animation_Effects"), isChartAnimation); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Animation"), panel); } - protected JPanel createAutoRefreshPane(VanChartPlot plot){ + protected JPanel createAutoRefreshPane(VanChartPlot plot) { autoRefreshPane = getMoreLabelPane(plot); @@ -254,7 +226,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { protected AutoRefreshPane getMoreLabelPane(VanChartPlot plot) { boolean isLargeModel = largeModel(plot); - return new AutoRefreshPane((VanChart) chart, isLargeModel); + return new AutoRefreshPane(chart, isLargeModel); } protected JPanel createHyperlinkPane() { @@ -262,11 +234,42 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Insert_Hyperlink"), superLink); } + private void checkLargeDataMode() { + largeModeThresholdNumberPane.setVisible(largeDataMode.getSelectedItem() == LargeDataModeType.OPEN_BEYOND_THRESHOLD); + + resetAttr(); + } + + private void resetAttr() { + if (largeDataMode.getSelectedItem() == LargeDataModeType.OPEN_BEYOND_THRESHOLD) { + VanChartPlot plot = this.chart.getPlot(); + + AttrLabel attrLabel = plot.getAttrLabelFromConditionCollection(); + if (attrLabel == null) { + attrLabel = plot.getDefaultAttrLabel(); + ConditionAttr defaultAttr = plot.getConditionCollection().getDefaultAttr(); + defaultAttr.addDataSeriesCondition(attrLabel); + } + attrLabel.setEnable(false); + + resetCustomCondition(plot.getConditionCollection()); + } + } + + + private void resetCustomCondition(ConditionCollection conditionCollection) { + for (int i = 0, len = conditionCollection.getConditionAttrSize(); i < len; i++) { + ConditionAttr conditionAttr = conditionCollection.getConditionAttr(i); + conditionAttr.remove(AttrLabel.class); + conditionAttr.remove(ScatterAttrLabel.class); + conditionAttr.remove(AttrEffect.class); + conditionAttr.remove(AttrLineEffect.class); - private void checkZoomPane() { - boolean zoomWidgetEnabled = zoomWidget.getSelectedIndex() == 0; - changeEnablePane.setVisible(zoomWidgetEnabled); - zoomType.setEnabled(!zoomWidgetEnabled); + VanChartAttrMarker attrMarker = conditionAttr.getExisted(VanChartAttrMarker.class); + if (attrMarker != null && !attrMarker.isCommon()) { + conditionAttr.remove(VanChartAttrMarker.class); + } + } } @Override @@ -274,29 +277,28 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { if (chart == null || chart.getPlot() == null) { return; } - this.chart = chart; - VanChartPlot plot = (VanChartPlot)chart.getPlot(); + this.chart = (VanChart) chart; + VanChartPlot plot = chart.getPlot(); - if(interactivePane == null){ + if (interactivePane == null) { this.remove(leftcontentPane); reLayoutContentPane(plot); } - if(plot.isSupportZoomDirection()){//支持缩放方向=方向+控件 - populateChartZoom((VanChart)chart); - checkZoomPane(); + + if (zoomPane != null) { + zoomPane.populateBean(this.chart.getZoomAttribute()); } - if (plot.getAxisPlotType() == AxisPlotType.RECTANGLE){ + if (plot.getAxisPlotType() == AxisPlotType.RECTANGLE) { populateChartAxisRotation(plot); } - populateChartTools((VanChart) chart); - populateChartAnimate(chart, plot); - populateAutoRefresh((VanChart)chart); + populateChartTools(this.chart); + populateLargeMode(plot); + populateChartAnimate(this.chart, plot); + populateAutoRefresh(this.chart); populateHyperlink(plot); - - checkZoomEnabled(); } @@ -312,25 +314,13 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { collapse.setSelected(vanChartTools.isHidden()); } - private void populateChartZoom(VanChart chart) { - VanChartZoom zoom = chart.getVanChartZoom(); - if(zoom == null){ - zoom = new VanChartZoom(); - } - zoomWidget.setSelectedIndex(zoom.isZoomVisible() ? 0 : 1); - zoomGesture.setSelectedIndex(zoom.isZoomGesture() ? 0 : 1); - zoomResize.setSelectedIndex(zoom.isZoomResize() ? 0 : 1); - if (zoom.getFrom() instanceof BaseFormula) { - from.populateBean(((BaseFormula) zoom.getFrom()).getContent()); - } else { - from.populateBean(Utils.objectToString(zoom.getFrom())); - } - if (zoom.getTo() instanceof BaseFormula) { - to.populateBean(((BaseFormula) zoom.getTo()).getContent()); - } else { - to.populateBean(Utils.objectToString(zoom.getTo())); + private void populateLargeMode(Plot plot) { + if (largeDataMode != null) { + LargeDataAttribute attribute = plot.getLargeDataAttribute(); + + largeDataMode.setSelectedItem(attribute.getLargeDataModeType()); + largeModeThresholdNumber.setValue(attribute.getLargeModeThresholdNumber()); } - zoomType.setSelectedItem(zoom.getZoomType()); } private void populateChartAxisRotation(VanChartPlot plot) { @@ -338,7 +328,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { } private void populateChartAnimate(Chart chart, Plot plot) { - if(plot.isSupportAnimate()) { + if (plot.isSupportAnimate()) { isChartAnimation.setSelectedIndex(chart.isJSDraw() ? 0 : 1); isChartAnimation.setEnabled(!largeModel(plot)); } @@ -349,11 +339,11 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { } protected void populateAutoRefresh(VanChart chart) { - VanChartPlot plot = (VanChartPlot)chart.getPlot(); + VanChartPlot plot = chart.getPlot(); RefreshMoreLabel refreshMoreLabel = chart.getRefreshMoreLabel(); - if(refreshMoreLabel == null) { - refreshMoreLabel = new RefreshMoreLabel(((VanChartPlot)chart.getPlot()).getAutoAttrTooltip()); + if (refreshMoreLabel == null) { + refreshMoreLabel = new RefreshMoreLabel(((VanChartPlot) chart.getPlot()).getAutoAttrTooltip()); } autoRefreshPane.populateBean(refreshMoreLabel); @@ -366,21 +356,24 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { return; } - VanChartPlot plot = (VanChartPlot)chart.getPlot(); + VanChart vanChart = (VanChart) chart; + VanChartPlot plot = chart.getPlot(); - if(plot.isSupportZoomDirection()){ - updateChartZoom((VanChart)chart); + if (zoomPane != null) { + vanChart.setZoomAttribute(zoomPane.updateBean()); } - if(plot.getAxisPlotType() == AxisPlotType.RECTANGLE){ - updateChartAxisRotation((VanChart)chart); + + if (plot.getAxisPlotType() == AxisPlotType.RECTANGLE) { + updateChartAxisRotation(vanChart); } - updateChartTools((VanChart)chart); - updateChartAnimate(chart, plot); - updateAutoRefresh((VanChart)chart); + updateChartTools(vanChart); + updateChartAnimate(vanChart, plot); + updateLargeData(plot); + updateAutoRefresh(vanChart); updateHyperlink(plot); } - protected void updateHyperlink(Plot plot){ + protected void updateHyperlink(Plot plot) { superLink.update(plot); } @@ -393,37 +386,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { chart.setVanChartTools(vanChartTools); } - private void updateChartZoom(VanChart chart) { - VanChartZoom zoom = chart.getVanChartZoom(); - if(zoom == null){ - zoom = new VanChartZoom(); - chart.setVanChartZoom(zoom); - } - zoom.setZoomVisible(zoomWidget.getSelectedIndex() == 0); - zoom.setZoomGesture(zoomGesture.getSelectedIndex() == 0); - zoom.setZoomResize(zoomResize.getSelectedIndex() == 0); - String fromString = from.updateBean(); - Object fromObject; - if (StableUtils.maybeFormula(fromString)) { - fromObject = BaseFormula.createFormulaBuilder().build(fromString); - } else { - fromObject = fromString; - } - zoom.setFrom(fromObject); - String toString = to.updateBean(); - Object toObject; - if (StableUtils.maybeFormula(toString)) { - toObject = BaseFormula.createFormulaBuilder().build(toString); - } else { - toObject = toString; - } - zoom.setTo(toObject); - zoom.setZoomType(zoomType.getSelectedItem()); - } - private void updateChartAxisRotation(VanChart chart) { //坐标轴和plot都需要这个属性,因为坐标轴和plot是分开画的 - VanChartPlot plot = (VanChartPlot) chart.getPlot(); + VanChartPlot plot = chart.getPlot(); plot.setAxisRotation(axisRotation.getSelectedIndex() == 0); //同时更新坐标轴旋转属性 for (VanChartAxis axis : ((VanChartRectanglePlot) plot).getXAxisList()) { @@ -435,14 +400,23 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { } //更新数据表属性 - if (plot.isAxisRotation()){ + if (plot.isAxisRotation()) { plot.getDataSheet().setVisible(false); } } + private void updateLargeData(Plot plot) { + if (largeDataMode != null) { + LargeDataAttribute attribute = new LargeDataAttribute(); + attribute.setLargeDataModeType((LargeDataModeType) largeDataMode.getSelectedItem()); + attribute.setLargeModeThresholdNumber(largeModeThresholdNumber.getValue()); + plot.setLargeDataAttribute(attribute); + } + } + private void updateChartAnimate(Chart chart, Plot plot) { - if(plot.isSupportAnimate()) { - chart.setJSDraw(isChartAnimation.getSelectedIndex()==0); + if (plot.isSupportAnimate()) { + chart.setJSDraw(isChartAnimation.getSelectedIndex() == 0); } } @@ -450,15 +424,15 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { private void updateAutoRefresh(VanChart chart) { RefreshMoreLabel refreshMoreLabel = chart.getRefreshMoreLabel(); - if(refreshMoreLabel == null) { - refreshMoreLabel = new RefreshMoreLabel(((VanChartPlot)chart.getPlot()).getAutoAttrTooltip()); + if (refreshMoreLabel == null) { + refreshMoreLabel = new RefreshMoreLabel(((VanChartPlot) chart.getPlot()).getAutoAttrTooltip()); chart.setRefreshMoreLabel(refreshMoreLabel); } autoRefreshPane.updateBean(refreshMoreLabel); } @Override - public Chart updateBean() { + public VanChart updateBean() { return null; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePaneWithMapZoom.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePaneWithMapZoom.java index ec1ed0d9db..3b4352b7a2 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePaneWithMapZoom.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePaneWithMapZoom.java @@ -1,19 +1,15 @@ package com.fr.van.chart.designer.other; -import com.fr.plugin.chart.attr.plot.VanChartPlot; - -import javax.swing.JPanel; -import java.awt.BorderLayout; +import com.fr.van.chart.designer.other.zoom.MapZoomPane; +import com.fr.van.chart.designer.other.zoom.ZoomPane; /** * Created by mengao on 2017/4/7. */ public class VanChartInteractivePaneWithMapZoom extends VanChartInteractivePaneWithOutSort { + @Override - protected JPanel createZoomPaneContent(JPanel zoomWidgetPane, JPanel zoomGesturePane, JPanel changeEnablePane, JPanel zoomTypePane, VanChartPlot plot) { - JPanel panel = new JPanel(new BorderLayout(0, 4)); - panel.add(zoomWidgetPane, BorderLayout.NORTH); - panel.add(zoomGesturePane, BorderLayout.CENTER); - return panel; + protected ZoomPane createZoomPane() { + return new MapZoomPane(); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/MapZoomPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/MapZoomPane.java new file mode 100644 index 0000000000..22395cd9e5 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/MapZoomPane.java @@ -0,0 +1,47 @@ +package com.fr.van.chart.designer.other.zoom; + +import com.fr.chartx.attr.ZoomAttribute; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; + +import java.awt.Component; + +/** + * Created by shine on 2019/08/28. + */ +public class MapZoomPane extends ZoomPane { + + private UIButtonGroup mapZoomWidget;//地图缩放控件 + private UIButtonGroup gestureZoomGroup;//地图手势缩放 + + @Override + protected Component[][] getSouthComps() { + mapZoomWidget = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open") + , Toolkit.i18nText("Fine-Design_Chart_Close")}, new Boolean[]{true, false}); + + gestureZoomGroup = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open") + , Toolkit.i18nText("Fine-Design_Chart_Close")}, new Boolean[]{true, false}); + + + return new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Zoom_Widget")), mapZoomWidget}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_ZoomGesture")), gestureZoomGroup} + }; + } + + @Override + public void populateBean(ZoomAttribute ob) { + super.populateBean(ob); + mapZoomWidget.setSelectedItem(ob.isMapZoomWidget()); + gestureZoomGroup.setSelectedItem(ob.isGestureZoom()); + } + + @Override + public ZoomAttribute updateBean() { + ZoomAttribute zoomAttribute = super.updateBean(); + zoomAttribute.setMapZoomWidget(mapZoomWidget.getSelectedItem()); + zoomAttribute.setGestureZoom(gestureZoomGroup.getSelectedItem()); + return zoomAttribute; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPane.java new file mode 100644 index 0000000000..dfbf2d640a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPane.java @@ -0,0 +1,252 @@ +package com.fr.van.chart.designer.other.zoom; + +import com.fr.chartx.attr.ZoomAttribute; +import com.fr.chartx.attr.ZoomInitialDisplayType; +import com.fr.chartx.attr.ZoomModeType; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.extended.chart.StringFormula; +import com.fr.general.ComparatorUtils; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; + +/** + * Created by shine on 2019/08/28. + */ +public class ZoomPane extends BasicBeanPane { + + private UIButtonGroup modeTypeButtonGroup; + + private JPanel customModePane; + private UIComboBox initialDisplayTypeComboBox; + private JPanel initialDisplayCardPane; + private UISpinner topCategorySpinner; + private TinyFormulaPane leftFormulaPane; + private TinyFormulaPane rightFormulaPane; + + private UIButtonGroup selectionZoomGroup; + + public ZoomPane() { + initComponent(); + } + + private void initComponent() { + + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; + double p = TableLayout.PREFERRED; + double[] columnSize = {f, e}; + + JPanel northPane = createNorthPane(f, p); + + initCustomModePane(columnSize, p); + + JPanel southPane = createSouthPane(f, p); + + this.setLayout(new BorderLayout(0, 6)); + + if (northPane != null) { + this.add(northPane, BorderLayout.NORTH); + } + if (customModePane != null) { + this.add(customModePane, BorderLayout.CENTER); + } + if (southPane != null) { + this.add(southPane, BorderLayout.SOUTH); + } + } + + protected JPanel createNorthPane(double f, double p) { + modeTypeButtonGroup = new UIButtonGroup(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Mode_Auto"), + Toolkit.i18nText("Fine-Design_Chart_Mode_Custom"), + Toolkit.i18nText("Fine-Design_Chart_Close") + }, new ZoomModeType[]{ZoomModeType.AUTO, ZoomModeType.CUSTOM, ZoomModeType.CLOSE}); + + modeTypeButtonGroup.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + checkCustomModePane(); + } + }); + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Zoom_Mode_type")), modeTypeButtonGroup} + }; + return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p} + , new double[]{f, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}); + } + + private JPanel createSouthPane(double f, double p) { + + Component[][] components = getSouthComps(); + + double[] rows = new double[components.length]; + Arrays.fill(rows, p); + + return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rows + , new double[]{f, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}); + } + + protected Component[][] getSouthComps() { + selectionZoomGroup = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open") + , Toolkit.i18nText("Fine-Design_Chart_Close")}, new Boolean[]{true, false}); + + return new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Selection_Zoom")), selectionZoomGroup} + }; + } + + protected void initCustomModePane(double[] columnSize, double p) { + initialDisplayTypeComboBox = new UIComboBox(new ZoomInitialDisplayType[]{ + ZoomInitialDisplayType.TOP_CATEGORY, + ZoomInitialDisplayType.LEFT_RIGHT_BOUNDARY}); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_InitialDisplay")), initialDisplayTypeComboBox} + }; + JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p}, columnSize); + + + initInitialDisplayCardPane(columnSize, p); + + customModePane = new JPanel(new BorderLayout(0, 6)); + customModePane.add(northPane, BorderLayout.NORTH); + customModePane.add(initialDisplayCardPane, BorderLayout.CENTER); + customModePane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + } + + private void initInitialDisplayCardPane(double[] columnSize, double p) { + topCategorySpinner = new UISpinner(1, Integer.MAX_VALUE, 1); + Component[][] components1 = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Category_Number")), topCategorySpinner} + }; + final JPanel topPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components1, new double[]{p}, columnSize); + + + leftFormulaPane = new TinyFormulaPane(); + rightFormulaPane = new TinyFormulaPane(); + Component[][] components2 = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Left_Boundary")), leftFormulaPane}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Right_Boundary")), rightFormulaPane} + }; + final JPanel leftRightPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components2, new double[]{p, p}, columnSize); + + initialDisplayCardPane = new JPanel(new CardLayout()) { + @Override + public Dimension getPreferredSize() { + return initialDisplayTypeComboBox.getSelectedIndex() == 0 ? topPane.getPreferredSize() : leftRightPane.getPreferredSize(); + } + }; + initialDisplayCardPane.add(topPane, ZoomInitialDisplayType.TOP_CATEGORY.toString()); + initialDisplayCardPane.add(leftRightPane, ZoomInitialDisplayType.LEFT_RIGHT_BOUNDARY.toString()); + initialDisplayTypeComboBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkInitialDisplayCardPane(); + } + }); + } + + private void checkCustomModePane() { + if (customModePane == null){ + return; + } + customModePane.setVisible(modeTypeButtonGroup.getSelectedItem() == ZoomModeType.CUSTOM); + } + + private void checkInitialDisplayCardPane() { + if (initialDisplayCardPane == null){ + return; + } + + CardLayout cardLayout = (CardLayout) initialDisplayCardPane.getLayout(); + if (ComparatorUtils.equals(initialDisplayTypeComboBox.getSelectedItem(), ZoomInitialDisplayType.TOP_CATEGORY)) { + cardLayout.show(initialDisplayCardPane, ZoomInitialDisplayType.TOP_CATEGORY.toString()); + } else { + cardLayout.show(initialDisplayCardPane, ZoomInitialDisplayType.LEFT_RIGHT_BOUNDARY.toString()); + } + } + + + @Override + public void populateBean(ZoomAttribute ob) { + if (modeTypeButtonGroup != null) { + modeTypeButtonGroup.setSelectedItem(ob.getModeType()); + } + + if (initialDisplayTypeComboBox != null){ + initialDisplayTypeComboBox.setSelectedItem(ob.getInitialDisplayType()); + } + + if (topCategorySpinner != null) { + topCategorySpinner.setValue(ob.getTopCategory()); + } + + if (ob.getLeft() != null && leftFormulaPane != null) { + leftFormulaPane.populateBean(ob.getLeft().getContent()); + } + if (ob.getRight() != null && rightFormulaPane != null) { + rightFormulaPane.populateBean(ob.getRight().getContent()); + } + + if (selectionZoomGroup != null) { + selectionZoomGroup.setSelectedItem(ob.isSelectionZoom()); + } + + checkInitialDisplayCardPane(); + checkCustomModePane(); + } + + @Override + public ZoomAttribute updateBean() { + ZoomAttribute zoomAttribute = new ZoomAttribute(); + + if (modeTypeButtonGroup != null) { + zoomAttribute.setModeType(modeTypeButtonGroup.getSelectedItem()); + } + + if (initialDisplayTypeComboBox != null) { + zoomAttribute.setInitialDisplayType((ZoomInitialDisplayType) initialDisplayTypeComboBox.getSelectedItem()); + } + + if (topCategorySpinner != null){ + zoomAttribute.setTopCategory((int) topCategorySpinner.getValue()); + } + + if (leftFormulaPane != null){ + zoomAttribute.setLeft(new StringFormula(leftFormulaPane.updateBean())); + } + + if (rightFormulaPane != null){ + zoomAttribute.setRight(new StringFormula(rightFormulaPane.updateBean())); + } + + if (selectionZoomGroup != null) { + zoomAttribute.setSelectionZoom(selectionZoomGroup.getSelectedItem()); + } + + return zoomAttribute; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPaneWithOutMode.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPaneWithOutMode.java new file mode 100644 index 0000000000..5edda21333 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPaneWithOutMode.java @@ -0,0 +1,18 @@ +package com.fr.van.chart.designer.other.zoom; + +import javax.swing.JPanel; + +/** + * Created by shine on 2019/08/28. + */ +public class ZoomPaneWithOutMode extends ZoomPane { + @Override + protected JPanel createNorthPane(double f, double p) { + return null; + } + + @Override + protected void initCustomModePane(double[] columnSize, double p) { + //do nothing + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java index d3a437ef25..2d4245148a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java @@ -8,12 +8,11 @@ import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; - +import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.plugin.chart.attr.VanChartLegend; import com.fr.stable.Constants; @@ -21,8 +20,8 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartFloatPositionPane; import com.fr.van.chart.designer.component.background.VanChartBackgroundWithOutImagePane; import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane; +import com.fr.van.chart.designer.style.component.LimitPane; -import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; @@ -55,11 +54,8 @@ public class VanChartPlotLegendPane extends BasicPane { protected UIButtonGroup location; protected UIToggleButton customFloatPositionButton; protected VanChartFloatPositionPane customFloatPositionPane; - protected UIButtonGroup limitSize; - protected UISpinner maxProportion; - private UILabel limitSizeTitle; - private JPanel maxProportionPane; + private LimitPane limitPane; //高亮显示的按钮 protected UIButtonGroup highlightButton; @@ -232,25 +228,8 @@ public class VanChartPlotLegendPane extends BasicPane { } protected JPanel createDisplayStrategy(){ - maxProportion = new UISpinner(0,100,1,30); - limitSize = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); - limitSizeTitle = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion")); - - - JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Size"),limitSize); - maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"),maxProportion,TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0,12,0,0)); - JPanel panel = new JPanel(new BorderLayout()); - panel.add(limitSizePane, BorderLayout.NORTH); - panel.add(maxProportionPane, BorderLayout.CENTER); - - limitSize.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkMaxProPortionUse(); - } - }); - return panel; + limitPane = new LimitPane(false); + return limitPane; } private JPanel createHighlightPane(){ @@ -276,15 +255,8 @@ public class VanChartPlotLegendPane extends BasicPane { //检查显示策略界面是否可用 protected void checkDisplayStrategyUse() { - limitSize.setEnabled(!customFloatPositionButton.isSelected()); - checkMaxProPortionUse(); - } - - //检查最大显示占比是否可用 - private void checkMaxProPortionUse() { - maxProportion.setVisible(limitSize.getSelectedIndex() == 0 && limitSize.isEnabled()); - maxProportionPane.setVisible(limitSize.getSelectedIndex() == 0 && limitSize.isEnabled()); - + GUICoreUtils.setEnabled(limitPane, !customFloatPositionButton.isSelected()); + limitPane.checkMaxProPortionUse(); } protected void checkBoxUse() { @@ -315,8 +287,7 @@ public class VanChartPlotLegendPane extends BasicPane { legend.setPosition(-1); } legend.setFloating(customFloatPositionButton.isSelected()); - legend.setLimitSize(limitSize.getSelectedIndex() == 0); - legend.setMaxHeight(maxProportion.getValue()); + legend.setLimitAttribute(limitPane.updateBean()); legend.setFloatPercentX(customFloatPositionPane.getFloatPosition_x()); legend.setFloatPercentY(customFloatPositionPane.getFloatPosition_y()); if(highlightButton != null && highlightButton.getSelectedItem() != null){ @@ -336,8 +307,7 @@ public class VanChartPlotLegendPane extends BasicPane { customFloatPositionButton.setSelected(legend.isFloating()); customFloatPositionPane.setFloatPosition_x(legend.getFloatPercentX()); customFloatPositionPane.setFloatPosition_y(legend.getFloatPercentY()); - limitSize.setSelectedIndex(legend.isLimitSize() ? 0 : 1); - maxProportion.setValue(legend.getMaxHeight()); + limitPane.populateBean(legend.getLimitAttribute()); if(highlightButton != null){ highlightButton.setSelectedItem(legend.isHighlight()); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java index 39d0b8f1bd..2e7ae32781 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java @@ -192,26 +192,12 @@ public class VanChartRangeLegendPane extends VanChartPlotLegendPane { public void populateBean(VanChartLegend legend) { VanChartRangeLegend scatterLegend = (VanChartRangeLegend)legend; if (scatterLegend != null) { - isLegendVisible.setSelected(scatterLegend.isLegendVisible()); - textAttrPane.populate(scatterLegend.getFRFont()); - borderPane.populate(scatterLegend); - backgroundPane.populate(scatterLegend); - if(!scatterLegend.isFloating()){ - location.setSelectedItem(scatterLegend.getPosition()); - } - customFloatPositionButton.setSelected(scatterLegend.isFloating()); - customFloatPositionPane.setFloatPosition_x(scatterLegend.getFloatPercentX()); - customFloatPositionPane.setFloatPosition_y(scatterLegend.getFloatPercentY()); - limitSize.setSelectedIndex(scatterLegend.isLimitSize() ? 0 : 1); - maxProportion.setValue(scatterLegend.getMaxHeight()); + //范围图例部分 legendTypeButton.setSelectedItem(scatterLegend.getLegendType()); gradualLegendPane.populate(scatterLegend.getGradualLegend()); sectionLegendPane.populate(scatterLegend.getSectionLegend()); - - if(highlightButton != null){ - highlightButton.setSelectedItem(legend.isHighlight()); - } + super.populateBean(scatterLegend); } checkAllUse(); this.checkHighlightVisible(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java index c99dccace9..01610a2457 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java @@ -11,12 +11,11 @@ import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; - +import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.plugin.chart.attr.VanChartTitle; import com.fr.plugin.chart.vanchart.VanChart; @@ -27,8 +26,8 @@ import com.fr.van.chart.designer.AbstractVanChartScrollPane; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartFloatPositionPane; import com.fr.van.chart.designer.component.background.VanChartBackgroundWithOutShadowWithRadiusPane; +import com.fr.van.chart.designer.style.component.LimitPane; -import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JPanel; import javax.swing.SwingConstants; @@ -60,9 +59,8 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { private UIToggleButton useHtml; private UIToggleButton customFloatPositionButton; private VanChartFloatPositionPane customFloatPositionPane; - private UIButtonGroup limitSize; - private UISpinner maxProportion; - private JPanel maxProportionPane; + + private LimitPane limitPane; protected VanChartStylePane parent; @@ -171,24 +169,8 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { } private JPanel createDisplayStrategy(){ - maxProportion = new UISpinner(0,100,1,30); - limitSize = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); - - JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Size"),limitSize); - maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"),maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0,12,0,0)); - JPanel panel = new JPanel(new BorderLayout()); - panel.add(limitSizePane, BorderLayout.NORTH); - panel.add(maxProportionPane, BorderLayout.CENTER); - - limitSize.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkMaxProPortionUse(); - } - }); - - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); + limitPane = new LimitPane(); + return limitPane; } private void initPositionListener(){ @@ -250,15 +232,10 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { //检查显示策略界面是否可用 private void checkDisplayStrategyUse() { - limitSize.setEnabled(!customFloatPositionButton.isSelected()); - checkMaxProPortionUse(); + GUICoreUtils.setEnabled(limitPane, !customFloatPositionButton.isSelected()); + limitPane.checkMaxProPortionUse(); } - //检查最大显示占比是否可用 - private void checkMaxProPortionUse() { - maxProportion.setVisible(limitSize.getSelectedIndex() == 0 && limitSize.isEnabled()); - maxProportionPane.setVisible(limitSize.getSelectedIndex() == 0 && limitSize.isEnabled()); - } /** * 弹出框的界面标题 @@ -301,8 +278,7 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { customFloatPositionButton.setSelected(title.isFloating()); customFloatPositionPane.setFloatPosition_x(title.getFloatPercentX()); customFloatPositionPane.setFloatPosition_y(title.getFloatPercentY()); - limitSize.setSelectedIndex(title.isLimitSize() ? 0 : 1); - maxProportion.setValue(title.getMaxHeight()); + limitPane.populateBean(title.getLimitAttribute()); checkAllUse(); } @@ -335,8 +311,7 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { } title.setUseHtml(useHtml.isSelected()); title.setFloating(customFloatPositionButton.isSelected()); - title.setLimitSize(limitSize.getSelectedIndex() == 0); - title.setMaxHeight(maxProportion.getValue()); + title.setLimitAttribute(limitPane.updateBean()); title.setFloatPercentX(customFloatPositionPane.getFloatPosition_x()); title.setFloatPercentY(customFloatPositionPane.getFloatPosition_y()); textAttrPane.update(textAttr); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java index ac88b9be4d..1d7c7c8c91 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java @@ -13,8 +13,8 @@ import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; -import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.style.FormatPane; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; @@ -23,19 +23,24 @@ import com.fr.design.style.color.ColorSelectBox; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.attr.axis.VanChartAxis; +import com.fr.plugin.chart.base.OverlapHandleType; import com.fr.plugin.chart.base.VanChartConstants; import com.fr.plugin.chart.type.AxisTickLineType; import com.fr.stable.Constants; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartHtmlLabelPane; import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.designer.style.component.LimitPane; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JPanel; import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Component; @@ -58,10 +63,14 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { protected UIButtonGroup showLabel; protected ChartTextAttrPane labelTextAttrPane; protected UINumberDragPane labelTextRotation; + + private UIButtonGroup overlapHandleTypeGroup; protected UIButtonGroup labelGapStyle; - protected UITextField labelGapValue; - protected JPanel labelPanel; + protected UISpinner labelGapValue; + protected JPanel labelPanel; + private JPanel labelGapStylePane; + private JPanel labelGapValuePane; protected LineComboBox axisLineStyle; protected ColorSelectBox axisLineColor; @@ -71,15 +80,12 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { protected UIButtonGroup position; protected UIButtonGroup reversed; - protected UIButtonGroup axisLimitSize; - protected UISpinner maxProportion; - protected JPanel maxProportionPane; + private LimitPane limitPane; protected UIButtonGroup valueFormatStyle; protected FormatPane valueFormat; protected JPanel centerPane; private VanChartHtmlLabelPane htmlLabelPane; - private JPanel labelGapValuePane; public VanChartBaseAxisPane(){ this(true); @@ -166,32 +172,22 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { } protected JPanel createLabelPane(double[] row, double[] col){ + double p = TableLayout.PREFERRED; showLabel = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Show"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hidden")}); labelTextAttrPane = getChartTextAttrPane(); - labelTextRotation = new UINumberDragPane(-ROTATION_MAX,ROTATION_MAX); - labelGapStyle = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fixed")}); - labelGapValue = new UITextField(); - Component[][] gapComponents = new Component[][]{ - new Component[]{ - FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TextRotation")), - UIComponentUtils.wrapWithBorderLayoutPane(labelTextRotation) - }, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Label_Interval")), labelGapStyle}, - }; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(gapComponents, row, col); - labelGapValuePane= TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText(""),labelGapValue, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - JPanel gapPanel = new JPanel(new BorderLayout()); - gapPanel.add(panel, BorderLayout.CENTER); - gapPanel.add(labelGapValuePane, BorderLayout.SOUTH); + JPanel rotationPane = createLabelRotationPane(col); + JPanel overlapPane = createLabelOverlapPane(); + - Component[][] components = new Component[][]{ + Component[][] components = new Component[][]{ new Component[]{labelTextAttrPane, null}, - new Component[]{gapPanel,null}, + new Component[]{rotationPane, null}, + new Component[]{overlapPane, null}, }; JPanel showLabelPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label"),showLabel); - labelPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + labelPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p, p}, col); labelPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,0)); showLabel.addActionListener(new ActionListener() { @Override @@ -199,16 +195,61 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { checkLabelPane(); } }); + JPanel jPanel = new JPanel(new BorderLayout()); + jPanel.add(showLabelPane, BorderLayout.NORTH); + jPanel.add(labelPanel, BorderLayout.CENTER); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_LABEL_TITLE, jPanel); + } + + private JPanel createLabelRotationPane(double[] col) { + labelTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX); + + Component[][] gapComponents = new Component[][]{ + new Component[]{ + FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TextRotation")), + UIComponentUtils.wrapWithBorderLayoutPane(labelTextRotation) + } + }; + return TableLayout4VanChartHelper.createGapTableLayoutPane(gapComponents, new double[]{TableLayout.PREFERRED}, col); + } + + private JPanel createLabelOverlapPane() { + + labelGapStyle = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), Toolkit.i18nText("Fine-Design_Chart_Fixed")}); + labelGapStylePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Label_Interval"), labelGapStyle, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + + labelGapValue = new UISpinner(0, Integer.MAX_VALUE, 1, 1); + labelGapValuePane = TableLayout4VanChartHelper.createGapTableLayoutPane(StringUtils.EMPTY, labelGapValue, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + + JPanel panel = new JPanel(new BorderLayout(0, 0)); + addOverlapGroupButton(panel); + panel.add(labelGapStylePane, BorderLayout.CENTER); + panel.add(labelGapValuePane, BorderLayout.SOUTH); + labelGapStyle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { checkLabelGapValuePane(); } }); - JPanel jPanel = new JPanel(new BorderLayout()); - jPanel.add(showLabelPane, BorderLayout.NORTH); - jPanel.add(labelPanel, BorderLayout.CENTER); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_LABEL_TITLE, jPanel); + + return panel; + } + + protected void addOverlapGroupButton(JPanel panel) { + overlapHandleTypeGroup = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Label_OverlapAbbreviate"), Toolkit.i18nText("Fine-Design_Chart_Label_OverlapInterval")}, + new OverlapHandleType[]{OverlapHandleType.ABBREVIATE, OverlapHandleType.INTERVAL}); + JPanel north = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Label_WhenOverlap"), overlapHandleTypeGroup, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + + panel.add(north, BorderLayout.NORTH); + + overlapHandleTypeGroup.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + checkLabelGapAndStylePane(); + } + }); + } protected ChartTextAttrPane getChartTextAttrPane(){ @@ -286,24 +327,8 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { } protected JPanel createDisplayStrategy(double[] row, double[] col){ - maxProportion = new UISpinner(0,100,1,30); - axisLimitSize = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); - - JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Size"),axisLimitSize); - maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"),maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0,12,0,0)); - JPanel panel = new JPanel(new BorderLayout()); - panel.add(limitSizePane, BorderLayout.NORTH); - panel.add(maxProportionPane, BorderLayout.CENTER); - - axisLimitSize.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkMaxProPortionUse(); - } - }); - - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); + limitPane = new LimitPane(); + return limitPane; } protected JPanel createValueStylePane(){ @@ -360,7 +385,6 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { protected void checkAllUse() { checkCardPane(); checkLabelPane(); - checkMaxProPortionUse(); } protected void checkCardPane() { @@ -381,24 +405,31 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { labelPanel.setVisible(enabled); } if(enabled){ - checkLabelGapValuePane(); + checkLabelGapAndStylePane(); } } } - protected void checkLabelGapValuePane() { - if(labelGapValuePane != null && labelGapStyle != null){ - labelGapValuePane.setVisible(labelGapStyle.getSelectedIndex() == 1); + private void checkLabelGapAndStylePane() { + if (overlapHandleTypeGroup != null && labelGapStylePane != null) { + boolean visible = overlapHandleTypeGroup.getSelectedItem() == OverlapHandleType.INTERVAL; + + labelGapStylePane.setVisible(visible); } + checkLabelGapValuePane(); } - //检查最大显示占比是否可用 - private void checkMaxProPortionUse() { - if(maxProportionPane != null && axisLimitSize != null){ - maxProportionPane.setVisible(axisLimitSize.getSelectedIndex() == 0 && axisLimitSize.isEnabled()); + protected void checkLabelGapValuePane() { + if (labelGapValuePane != null && labelGapStyle != null) { + boolean visible = labelGapStyle.getSelectedIndex() == 1; + if (overlapHandleTypeGroup != null) { + visible = visible && overlapHandleTypeGroup.getSelectedItem() == OverlapHandleType.INTERVAL; + } + labelGapValuePane.setVisible(visible); } } + /** * 是否是指定类型 * @param ob 对象 @@ -477,11 +508,14 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { if(labelTextRotation != null){ labelTextRotation.populateBean((double)labelTextAttr.getRotation()); } + if (overlapHandleTypeGroup != null) { + overlapHandleTypeGroup.setSelectedItem(axis.getOverlapHandleType()); + } if(labelGapStyle != null){ labelGapStyle.setSelectedIndex(axis.isAutoLabelGap() ? 0 : 1); } if(labelGapValue != null){ - labelGapValue.setText(axis.getLabelNumber().getContent()); + labelGapValue.setValue(axis.getIntervalNumber()); } } @@ -516,13 +550,9 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { //显示策略 private void populateDisplayStrategy(VanChartAxis axis) { - if(axisLimitSize != null){ - axisLimitSize.setSelectedIndex(axis.isLimitSize() ? 0 : 1); + if (limitPane != null) { + limitPane.populateBean(axis.getLimitAttribute()); } - if(maxProportion != null){ - maxProportion.setValue(axis.getMaxHeight()); - } - } //格式 @@ -597,15 +627,14 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { if(labelTextRotation != null){ labelTextAttr.setRotation(labelTextRotation.updateBean().intValue()); } + if (overlapHandleTypeGroup != null) { + axis.setOverlapHandleType(overlapHandleTypeGroup.getSelectedItem()); + } if(labelGapStyle != null){ axis.setAutoLabelGap(labelGapStyle.getSelectedIndex() == 0); } if(labelGapValue != null){ - if(axis.isAutoLabelGap()){ - axis.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build("1")); - } else { - axis.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build(labelGapValue.getText())); - } + axis.setIntervalNumber((int) labelGapValue.getValue()); } } @@ -637,11 +666,8 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { //显示策略 private void updateDisplayStrategy(VanChartAxis axis){ - if(axisLimitSize != null){ - axis.setLimitSize(axisLimitSize.getSelectedIndex() == 0); - } - if(maxProportion != null){ - axis.setMaxHeight(maxProportion.getValue()); + if (limitPane != null) { + axis.setLimitAttribute(limitPane.updateBean()); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java index 3a43866a23..74dbf7221b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java @@ -17,7 +17,6 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.general.DateUtils; import com.fr.log.FineLoggerFactory; - import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartTimeAxis; import com.fr.plugin.chart.base.VanChartConstants; @@ -58,6 +57,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { super(isXAxis); } + @Override protected JPanel createContentPane(boolean isXAxis){ double p = TableLayout.PREFERRED; @@ -80,6 +80,11 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } + @Override + protected void addOverlapGroupButton(JPanel panel) { + //do nothing + } + private JPanel createValueDefinition(){ timeMinMaxValuePane = new TimeMinMaxValuePane(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), timeMinMaxValuePane); @@ -90,6 +95,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { return PlotFactory.createAutoFormatPane(); } + @Override protected void checkFormatType() { valueFormat.setComboBoxModel(true); } @@ -101,6 +107,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { timeMinMaxValuePane.update(timeAxis); } + @Override public VanChartTimeAxis updateBean(String axisName, int position) { VanChartTimeAxis axis = new VanChartTimeAxis(axisName, VanChartConstants.AXIS_BOTTOM); updateBean(axis); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java index 39ae32372f..3b271f2b3a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java @@ -7,7 +7,6 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; - import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartValueAxis; import com.fr.stable.StringUtils; @@ -39,6 +38,7 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane { super(isXAxis); } + @Override protected JPanel createContentPane(boolean isXAxis){ double p = TableLayout.PREFERRED; @@ -61,6 +61,11 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane { return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } + @Override + protected void addOverlapGroupButton(JPanel panel) { + //do nothing + } + protected JPanel createMinMaxValuePane(double[] row, double[] col){ JPanel panel = createCommenValuePane(row,col); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), panel); @@ -123,6 +128,7 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Axis"); } + @Override public void populateBean(VanChartAxis axis){ VanChartValueAxis valueAxis = (VanChartValueAxis)axis; super.populateBean(valueAxis); @@ -150,6 +156,7 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane { } } + @Override public VanChartValueAxis updateBean(String axisName, int position){ VanChartValueAxis axis = new VanChartValueAxis(axisName, position); updateBean(axis); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarYAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarYAxisPane.java index f7567ed211..d30d245731 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarYAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarYAxisPane.java @@ -54,6 +54,7 @@ public class VanChartRadarYAxisPane extends VanChartValueAxisPane { return new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); } + @Override protected JPanel createMinMaxValuePane(double[] row, double[] col) { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java index 282ad45129..d01198c24e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java @@ -5,9 +5,9 @@ import com.fr.base.Utils; import com.fr.design.beans.BasicBeanPane; import com.fr.design.formula.TinyFormulaPane; import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.style.FRFontPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; @@ -16,12 +16,12 @@ import com.fr.design.style.color.ColorSelectBox; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; import com.fr.general.GeneralUtils; - import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.attr.axis.VanChartAlertValue; -import com.fr.plugin.chart.base.VanChartConstants; +import com.fr.plugin.chart.type.LineType; import com.fr.stable.Constants; import com.fr.stable.StableUtils; +import com.fr.van.chart.designer.component.LineTypeComboBox; import javax.swing.BoxLayout; import javax.swing.JPanel; @@ -42,7 +42,8 @@ public class VanChartAlertValuePane extends BasicBeanPane { private static final long serialVersionUID = -1208941770684286439L; private UIButtonGroup alertAxis; protected TinyFormulaPane alertValue; - protected LineComboBox alertLineStyle; + protected LineTypeComboBox alertLineStyle;//线型 + private UISpinner lineWidthSpinner;//线宽 protected ColorSelectBox alertLineColor; private UIButtonGroup alertTextPosition; @@ -63,7 +64,8 @@ public class VanChartAlertValuePane extends BasicBeanPane { //設置大小,防止文本過長導致界面“變形” alertValue.setPreferredSize(new Dimension(VALUE_WD, HT)); - alertLineStyle = new LineComboBox(VanChartConstants.ALERT_LINE_STYLE); + alertLineStyle = new LineTypeComboBox(new LineType[]{LineType.NORMAL, LineType.DASH}); + lineWidthSpinner = new UISpinner(0.5, Integer.MAX_VALUE, 0.5, 2); alertLineColor = new ColorSelectBox(100); alertTextPosition = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Top"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Bottom")}); alertText = new TinyFormulaPane(); @@ -95,7 +97,7 @@ public class VanChartAlertValuePane extends BasicBeanPane { { double p = TableLayout.PREFERRED; double[] columnSize = {p,p}; - double[] rowSize = {p,p,p,p}; + double[] rowSize = {p,p,p,p,p}; Component[][] components = getTopPaneComponents(); return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); @@ -106,6 +108,7 @@ public class VanChartAlertValuePane extends BasicBeanPane { new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position")),alertAxis}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Value")),alertValue}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")),alertLineStyle}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Width")), lineWidthSpinner}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),alertLineColor}, }; } @@ -154,7 +157,8 @@ public class VanChartAlertValuePane extends BasicBeanPane { checkPositionPane(); alertValue.populateBean(Utils.objectToString(chartAlertValue.getAlertValueFormula())); - alertLineStyle.setSelectedLineStyle(chartAlertValue.getLineStyle().getLineStyle()); + alertLineStyle.setSelectedItem(chartAlertValue.getLineStyle().getLineType()); + lineWidthSpinner.setValue(chartAlertValue.getLineStyle().getLineWidth()); alertLineColor.setSelectObject(chartAlertValue.getLineColor().getSeriesColor()); if(VanChartAttrHelper.isXAxis(chartAlertValue.getAxisName())){ @@ -178,7 +182,8 @@ public class VanChartAlertValuePane extends BasicBeanPane { chartAlertValue.setAlertValueFormula(BaseFormula.createFormulaBuilder().build(alertValue.updateBean())); chartAlertValue.getLineColor().setSeriesColor(alertLineColor.getSelectObject()); - chartAlertValue.getLineStyle().setLineStyle(alertLineStyle.getSelectedLineStyle()); + chartAlertValue.getLineStyle().setLineType((LineType) alertLineStyle.getSelectedItem()); + chartAlertValue.getLineStyle().setLineWidth(lineWidthSpinner.getValue()); String contentString = alertText.updateBean(); Object contentObj; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java index 08c474c3ed..d0f899f614 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java @@ -4,14 +4,16 @@ import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.style.color.ColorSelectBox; import com.fr.general.ComparatorUtils; - import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; +import com.fr.plugin.chart.type.LineType; import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.component.LineTypeComboBox; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -39,11 +41,21 @@ public class VanChartAxisAreaPane extends BasicBeanPane { private ColorSelectBox verticalColorBackground; protected BackgroundListControlPane customIntervalBackground; + private LineTypeComboBox horizonLineType;//横向线型 + private LineTypeComboBox verticalLineType;//纵向线型 + private JPanel horizontalColorPane; + private JPanel verticalColorPane; + public VanChartAxisAreaPane() { initComponents(); } protected void initComponents() { + horizontalGridLine = new ColorSelectBox(100); + verticalGridLine = new ColorSelectBox(100); + horizonLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.NORMAL, LineType.DASH}); + verticalLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.NORMAL, LineType.DASH}); + double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; @@ -52,7 +64,7 @@ public class VanChartAxisAreaPane extends BasicBeanPane { double[] rowSize = {p, p, p}; Component[][] components = new Component[][]{ - new Component[]{createGridLinePane(new double[]{p, p, p}, new double[]{f, e})}, + new Component[]{createGridLinePane()}, new Component[]{createAlertLinePane()}, new Component[]{createIntervalPane(new double[]{p, p, p, p}, new double[]{f, s})}, }; @@ -61,25 +73,62 @@ public class VanChartAxisAreaPane extends BasicBeanPane { this.add(panel, BorderLayout.CENTER); } - private JPanel createGridLinePane(double[] row, double[] col) { - horizontalGridLine = new ColorSelectBox(100); - verticalGridLine = new ColorSelectBox(100); - Component[][] components = getGridLinePaneComponents(); - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel); - } + protected JPanel createGridLinePane() { - protected Component[][] getGridLinePaneComponents() { - return new Component[][]{ + Component[][] upComponent = new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal")), horizontalGridLine}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical")), verticalGridLine}, + new Component[]{null, horizontalGridLine} + }; + horizontalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(upComponent); + + Component[][] downComponent = new Component[][]{ + new Component[]{null,null}, + new Component[]{null, verticalGridLine} }; + verticalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(downComponent); + + horizonLineType.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (horizontalGridLine == null || horizonLineType == null){ + return; + } + horizontalColorPane.setVisible(horizonLineType.getSelectedItem() != LineType.NONE); + } + }); + + verticalLineType.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (verticalGridLine == null || verticalLineType == null){ + return; + } + verticalColorPane.setVisible(verticalLineType.getSelectedItem() != LineType.NONE); + } + }); + + checkColorBoxVisible(); + + JPanel horizonLineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal"), horizonLineType); + JPanel horizontal = new JPanel(new BorderLayout()); + horizontal.add(horizonLineTypePane, BorderLayout.NORTH); + horizontal.add(horizontalColorPane, BorderLayout.CENTER); + + JPanel verticalLineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical"), verticalLineType); + JPanel vertical = new JPanel(new BorderLayout()); + vertical.add(verticalLineTypePane, BorderLayout.NORTH); + vertical.add(verticalColorPane, BorderLayout.CENTER); + + JPanel panel = new JPanel(new BorderLayout(0, 4)); + panel.add(horizontal, BorderLayout.NORTH); + panel.add(vertical, BorderLayout.CENTER); + + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel); } protected JPanel createAlertLinePane() { alertLine = getAlertLinePane(); - JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Alert_Line"), alertLine); + JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Alert_Line"), alertLine); alertLine.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); return panel; } @@ -89,7 +138,7 @@ public class VanChartAxisAreaPane extends BasicBeanPane { } protected JPanel createIntervalPane(double[] row, double[] col) { - isDefaultIntervalBackground = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Default_Interval"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Interval_Background")}); + isDefaultIntervalBackground = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Default_Interval"), Toolkit.i18nText("Fine-Design_Chart_Custom_Interval_Background")}); horizontalColorBackground = new ColorSelectBox(100); verticalColorBackground = new ColorSelectBox(100); Component[][] components = getIntervalPaneComponents(); @@ -99,8 +148,8 @@ public class VanChartAxisAreaPane extends BasicBeanPane { cardLayout = new CardLayout(); centerPane = new JPanel(cardLayout); - centerPane.add(defaultPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Default_Interval")); - centerPane.add(customIntervalBackground, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Interval_Background")); + centerPane.add(defaultPane, Toolkit.i18nText("Fine-Design_Chart_Default_Interval")); + centerPane.add(customIntervalBackground, Toolkit.i18nText("Fine-Design_Chart_Custom_Interval_Background")); isDefaultIntervalBackground.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -108,10 +157,10 @@ public class VanChartAxisAreaPane extends BasicBeanPane { } }); JPanel intervalPane = new JPanel(new BorderLayout(0, 6)); - JPanel panel1 = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Interval_Background"), isDefaultIntervalBackground); + JPanel panel1 = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Interval_Background"), isDefaultIntervalBackground); intervalPane.add(panel1, BorderLayout.NORTH); intervalPane.add(centerPane, BorderLayout.CENTER); - JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Interval_Background"), intervalPane); + JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Interval_Background"), intervalPane); intervalPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); return panel; } @@ -123,16 +172,16 @@ public class VanChartAxisAreaPane extends BasicBeanPane { protected Component[][] getIntervalPaneComponents() { return new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal")), horizontalColorBackground}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical")), verticalColorBackground}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal")), horizontalColorBackground}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical")), verticalColorBackground}, }; } private void checkCardPane() { if (isDefaultIntervalBackground.getSelectedIndex() == 0) { - cardLayout.show(centerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Default_Interval")); + cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Default_Interval")); } else { - cardLayout.show(centerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Interval_Background")); + cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Custom_Interval_Background")); } } @@ -142,6 +191,7 @@ public class VanChartAxisAreaPane extends BasicBeanPane { public void populateBean(Plot plot) { VanChartRectanglePlot rectanglePlot = (VanChartRectanglePlot) plot; + checkColorBoxVisible(); populateGridLine(rectanglePlot); @@ -155,9 +205,11 @@ public class VanChartAxisAreaPane extends BasicBeanPane { checkCardPane(); } - protected void populateGridLine(VanChartRectanglePlot rectanglePlot) { + private void populateGridLine(VanChartRectanglePlot rectanglePlot) { horizontalGridLine.setSelectObject(rectanglePlot.getDefaultYAxis().getMainGridColor()); verticalGridLine.setSelectObject(rectanglePlot.getDefaultXAxis().getMainGridColor()); + horizonLineType.setSelectedItem(rectanglePlot.getDefaultYAxis().getGridLineType()); + verticalLineType.setSelectedItem(rectanglePlot.getDefaultXAxis().getGridLineType()); } @@ -179,9 +231,11 @@ public class VanChartAxisAreaPane extends BasicBeanPane { customIntervalBackground.update(plot, isDefaultIntervalBackground.getSelectedIndex() == 0); } - protected void updateGirdLine(VanChartRectanglePlot rectanglePlot) { + private void updateGirdLine(VanChartRectanglePlot rectanglePlot) { rectanglePlot.getDefaultYAxis().setMainGridColor(horizontalGridLine.getSelectObject()); rectanglePlot.getDefaultXAxis().setMainGridColor(verticalGridLine.getSelectObject()); + rectanglePlot.getDefaultYAxis().setGridLineType((LineType)horizonLineType.getSelectedItem()); + rectanglePlot.getDefaultXAxis().setGridLineType((LineType)verticalLineType.getSelectedItem()); } /** @@ -199,4 +253,14 @@ public class VanChartAxisAreaPane extends BasicBeanPane { public Plot updateBean() { return null; } + + private void checkColorBoxVisible() { + if (horizontalColorPane != null && horizonLineType != null){ + horizontalColorPane.setVisible(horizonLineType.getSelectedItem() != LineType.NONE); + } + + if (verticalColorPane != null && verticalLineType != null){ + verticalColorPane.setVisible(verticalLineType.getSelectedItem() != LineType.NONE); + } + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAxisAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAxisAreaPane.java index a304b0a59d..687516c357 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAxisAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAxisAreaPane.java @@ -2,12 +2,16 @@ package com.fr.van.chart.designer.style.background.radar; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ilable.UILabel; - +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.background.AlertLineListControlPane; import com.fr.van.chart.designer.style.background.BackgroundListControlPane; import com.fr.van.chart.designer.style.background.VanChartAxisAreaPane; +import javax.swing.JPanel; import java.awt.Component; +import java.util.Arrays; /** * 样式-背景-绘图区背景-雷达图只有Y轴的配置(间隔背景、网格线、警戒线) @@ -17,11 +21,21 @@ public class VanChartRadarAxisAreaPane extends VanChartAxisAreaPane { private static final long serialVersionUID = 2459614679918546393L; //雷达图只有横向的y轴的网格线配置 - protected Component[][] getGridLinePaneComponents() { - return new Component[][]{ + @Override + protected JPanel createGridLinePane() { + + Component[][] components = new Component[][]{ new Component[]{null,null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),horizontalGridLine}, }; + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] row = new double[components.length]; + Arrays.fill(row, p); + double[] col = {f, e}; + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel); } protected Component[][] getIntervalPaneComponents() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/component/LimitPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/component/LimitPane.java new file mode 100644 index 0000000000..4fd8c77d4b --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/component/LimitPane.java @@ -0,0 +1,85 @@ +package com.fr.van.chart.designer.style.component; + +import com.fr.chartx.attr.LimitAttribute; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * Created by shine on 2019/08/28. + */ +public class LimitPane extends BasicBeanPane { + + private UIButtonGroup autoCustomTypeGroup; + private UISpinner maxProportion; + private JPanel maxProportionPane; + + public LimitPane() { + this(true); + } + + public LimitPane(boolean hasTitle) { + initComponent(hasTitle); + } + + private void initComponent(boolean hasTitle) { + maxProportion = new UISpinner(0, 100, 1, 30); + autoCustomTypeGroup = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Mode_Auto") + , Toolkit.i18nText("Fine-Design_Chart_Mode_Custom")}, new Boolean[]{true, false}); + + JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Area_Size"), autoCustomTypeGroup); + maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"), maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); + JPanel panel = new JPanel(new BorderLayout()); + panel.add(limitSizePane, BorderLayout.NORTH); + panel.add(maxProportionPane, BorderLayout.CENTER); + + autoCustomTypeGroup.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkMaxProPortionUse(); + } + }); + + this.setLayout(new BorderLayout()); + if (hasTitle) { + JPanel contentPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); + this.add(contentPane); + } else { + this.add(panel); + } + } + + //检查最大显示占比是否可用 + public void checkMaxProPortionUse() { + maxProportion.setVisible(!autoCustomTypeGroup.getSelectedItem() && autoCustomTypeGroup.isEnabled()); + maxProportionPane.setVisible(!autoCustomTypeGroup.getSelectedItem() && autoCustomTypeGroup.isEnabled()); + } + + @Override + public void populateBean(LimitAttribute ob) { + autoCustomTypeGroup.setSelectedItem(ob.isAuto()); + maxProportion.setValue(ob.getMaxSize()); + } + + @Override + public LimitAttribute updateBean() { + LimitAttribute attribute = new LimitAttribute(); + attribute.setAuto(autoCustomTypeGroup.getSelectedItem()); + attribute.setMaxSize(maxProportion.getValue()); + return attribute; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index 012c410a89..48c45eb46c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java @@ -5,20 +5,23 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.style.color.ColorSelectBox; - import com.fr.plugin.chart.attr.plot.VanChartLabelPositionPlot; import com.fr.plugin.chart.base.AttrLabelDetail; import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.OverlapHandleType; import com.fr.stable.Constants; import com.fr.van.chart.designer.PlotFactory; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.VanChartStylePane; +import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; @@ -38,7 +41,10 @@ public class VanChartPlotLabelDetailPane extends BasicPane { protected BasicBeanPane dataLabelContentPane; protected UIButtonGroup position; - protected UIButtonGroup autoAdjust; + + private UIButtonGroup allowOverlap; + private UIComboBox overlapHandleType; + protected UIToggleButton tractionLine; protected UIButtonGroup style; @@ -118,8 +124,11 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } position = new UIButtonGroup(names, values); - autoAdjust = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_On"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); + allowOverlap = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_YES"), + Toolkit.i18nText("Fine-Design_Chart_NO")}, new Boolean[]{true, false}); + overlapHandleType = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Chart_Label_OverlapHide"), + Toolkit.i18nText("Fine-Design_Chart_Label_OverlapAdjust")}); Component[][] comps = new Component[2][2]; @@ -134,13 +143,33 @@ public class VanChartPlotLabelDetailPane extends BasicPane { panel.add(tractionLinePane, BorderLayout.SOUTH); initPositionListener(); } else if(PlotFactory.plotAutoAdjustLabelPosition(plot)){ - panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Auto_Adjust"),autoAdjust), BorderLayout.SOUTH); + panel.add(createOverlapLabelPane(), BorderLayout.SOUTH); } return panel; } return new JPanel(); } + private JPanel createOverlapLabelPane() { + allowOverlap.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + checkOverlap(); + } + }); + + JPanel north = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Label_AllowOverlap"), allowOverlap); + JPanel center = new JPanel(new BorderLayout()); + center.add(overlapHandleType, BorderLayout.CENTER); + center.setBorder(BorderFactory.createEmptyBorder(0, 78, 0, 0)); + + JPanel result = new JPanel(new BorderLayout(0, 6)); + result.add(north, BorderLayout.NORTH); + result.add(center, BorderLayout.CENTER); + + return result; + } + protected JPanel getLabelPositionPane (Component[][] comps, double[] row, double[] col){ JPanel panel = TableLayoutHelper.createTableLayoutPane(comps,row,col); return createTableLayoutPaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout"), panel); @@ -208,10 +237,16 @@ public class VanChartPlotLabelDetailPane extends BasicPane { private void checkAllUse() { checkStyleUse(); - if(tractionLine == null){ - return; + checkOverlap(); + if (tractionLine != null) { + checkPositionEnabled(); + } + } + + private void checkOverlap() { + if (overlapHandleType != null && allowOverlap != null) { + overlapHandleType.setVisible(!allowOverlap.getSelectedItem()); } - checkPositionEnabled(); } private void checkStyleUse() { @@ -235,8 +270,11 @@ public class VanChartPlotLabelDetailPane extends BasicPane { if(tractionLine != null){ tractionLine.setSelected(detail.isShowGuidLine()); } - if(autoAdjust != null){ - autoAdjust.setSelectedIndex(detail.isAutoAdjust() == true ? 0 : 1); + if (allowOverlap != null) { + allowOverlap.setSelectedItem(detail.isAllowOverlap()); + } + if (overlapHandleType != null) { + overlapHandleType.setSelectedIndex(detail.getOverlapHandleType() == OverlapHandleType.HIDE ? 0 : 1); } style.setSelectedIndex(detail.isCustom() ? 1 : 0); textFontPane.populate(detail.getTextAttr()); @@ -259,7 +297,13 @@ public class VanChartPlotLabelDetailPane extends BasicPane { position.setSelectedItem(detail.getPosition()); } - detail.setAutoAdjust(autoAdjust != null && autoAdjust.getSelectedItem()); + if (allowOverlap != null) { + detail.setAllowOverlap(allowOverlap.getSelectedItem()); + } + + if (overlapHandleType != null) { + detail.setOverlapHandleType(overlapHandleType.getSelectedIndex() == 0 ? OverlapHandleType.HIDE : OverlapHandleType.ADJUST); + } if(tractionLine != null){ detail.setShowGuidLine(tractionLine.isSelected() && detail.getPosition() == Constants.OUTSIDE); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java index efc91258a0..6dfc4f6f32 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java @@ -1,8 +1,5 @@ package com.fr.van.chart.designer.style.series; -import com.fr.base.chart.chartdata.model.DataProcessor; -import com.fr.base.chart.chartdata.model.LargeDataModel; -import com.fr.base.chart.chartdata.model.NormalDataModel; import com.fr.chart.base.AttrAlpha; import com.fr.chart.base.AttrBorder; import com.fr.chart.base.ChartConstants; @@ -10,11 +7,9 @@ import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; import com.fr.design.gui.frpane.UINumberDragPane; -import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.style.ChartFillStylePane; import com.fr.design.mainframe.chart.gui.style.series.AbstractPlotSeriesPane; - import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; @@ -28,6 +23,7 @@ import com.fr.plugin.chart.base.VanChartAttrTrendLine; import com.fr.plugin.chart.map.line.condition.AttrLineEffect; import com.fr.plugin.chart.scatter.attr.ScatterAttrLabel; import com.fr.van.chart.custom.style.VanChartCustomStylePane; +import com.fr.van.chart.designer.PlotFactory; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartAreaSeriesFillColorPane; import com.fr.van.chart.designer.component.VanChartBeautyPane; @@ -41,8 +37,6 @@ import com.fr.van.chart.pie.RadiusCardLayoutPane; import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.awt.BorderLayout; /** @@ -73,11 +67,9 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP private RadiusCardLayoutPane radiusPane;//半径设置界面 private JPanel radiusPaneWithTitle; - private UIButtonGroup largeDataModelGroup;//大数据模式 - protected JPanel contentPane; - public VanChartAbstractPlotSeriesPane(ChartStylePane parent, Plot plot){ + public VanChartAbstractPlotSeriesPane(ChartStylePane parent, Plot plot) { super(parent, plot); } @@ -110,17 +102,17 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP } //获取颜色面板 - protected JPanel getColorPane () { + protected JPanel getColorPane() { JPanel panel = new JPanel(new BorderLayout()); stylePane = createStylePane(); setColorPaneContent(panel); JPanel colorPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color"), panel); - panel.setBorder(BorderFactory.createEmptyBorder(10,5,0,0)); + panel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); return panel.getComponentCount() == 0 ? null : colorPane; } //设置色彩面板内容 - protected void setColorPaneContent (JPanel panel) { + protected void setColorPaneContent(JPanel panel) { if (stylePane != null) { panel.add(stylePane, BorderLayout.CENTER); } @@ -165,80 +157,26 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP protected JPanel createRadiusPane() { radiusPane = initRadiusPane(); radiusPaneWithTitle = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Radius_Set"), radiusPane); - return ((VanChartPlot)plot).isInCustom() ? null : radiusPaneWithTitle; + return ((VanChartPlot) plot).isInCustom() ? null : radiusPaneWithTitle; } - protected JPanel createLargeDataModelPane() { - largeDataModelGroup = createLargeDataModelGroup(); - largeDataModelGroup.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - checkLarge(); - } - }); - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Large_Model"), largeDataModelGroup); - return createLargeDataModelPane(panel); - } - - protected void checkLarge() { - if(largeModel()) { - AttrLabel attrLabel = ((VanChartPlot) plot).getAttrLabelFromConditionCollection(); - if (attrLabel == null) { - attrLabel = ((VanChartPlot) this.plot).getDefaultAttrLabel(); - ConditionAttr defaultAttr = plot.getConditionCollection().getDefaultAttr(); - defaultAttr.addDataSeriesCondition(attrLabel); - } - attrLabel.setEnable(false); - - resetCustomCondition(plot.getConditionCollection()); - } - - - checkCompsEnabledWithLarge(); - } - - protected void checkCompsEnabledWithLarge() { - if(markerPane != null && largeDataModelGroup != null){ - markerPane.checkLargePlot(largeModel()); + protected void checkCompsEnabledWithLarge(Plot plot) { + if (markerPane != null) { + markerPane.checkLargePlot(largeModel(plot)); } } protected void checkLinePane() { - if(lineTypePane != null && largeDataModelGroup != null){ - lineTypePane.checkLarge(largeModel()); + if (lineTypePane != null) { + lineTypePane.checkLarge(largeModel(plot)); } } - protected boolean largeModel() { - return largeDataModelGroup != null && largeDataModelGroup.getSelectedIndex() == 0; + protected boolean largeModel(Plot plot) { + return PlotFactory.largeDataModel(plot); } - protected void resetCustomCondition(ConditionCollection conditionCollection) { - for(int i = 0, len = conditionCollection.getConditionAttrSize(); i < len; i++){ - ConditionAttr conditionAttr = conditionCollection.getConditionAttr(i); - conditionAttr.remove(AttrLabel.class); - conditionAttr.remove(ScatterAttrLabel.class); - conditionAttr.remove(AttrEffect.class); - conditionAttr.remove(AttrLineEffect.class); - - VanChartAttrMarker attrMarker = conditionAttr.getExisted(VanChartAttrMarker.class); - if(attrMarker != null && !attrMarker.isCommon()){ - conditionAttr.remove(VanChartAttrMarker.class); - } - } - } - - protected JPanel createLargeDataModelPane(JPanel jPanel) { - JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Large_Data"), jPanel); - return panel; - } - - protected UIButtonGroup createLargeDataModelGroup() { - String[] strings = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}; - DataProcessor[] values = new DataProcessor[]{new LargeDataModel(), new NormalDataModel()}; - return new UIButtonGroup(strings, values); - } protected RadiusCardLayoutPane initRadiusPane() { return new RadiusCardLayoutPane(); @@ -258,7 +196,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP //堆积和坐标轴设置(自定义柱形图等用到) protected JPanel createStackedAndAxisPane() { stackAndAxisEditPane = new VanChartStackedAndAxisListControlPane(); - stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); + stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); return stackAndAxisEditExpandablePane; } @@ -272,7 +210,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP * 更新Plot的属性到系列界面 */ public void populateBean(Plot plot) { - if(plot == null) { + if (plot == null) { return; } @@ -280,24 +218,20 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP super.populateBean(plot);//配色 - if(stylePane != null){//风格 + if (stylePane != null) {//风格 stylePane.populateBean(plot.getPlotStyle()); } - if(largeDataModelGroup != null){ - largeDataModelGroup.setSelectedItem(plot.getDataProcessor()); - } - - if(stackAndAxisEditPane != null && plot instanceof VanChartRectanglePlot){//堆积和坐标轴 - VanChartRectanglePlot rectanglePlot = (VanChartRectanglePlot)plot; - if(rectanglePlot.isCustomChart()){ + if (stackAndAxisEditPane != null && plot instanceof VanChartRectanglePlot) {//堆积和坐标轴 + VanChartRectanglePlot rectanglePlot = (VanChartRectanglePlot) plot; + if (rectanglePlot.isCustomChart()) { stackAndAxisEditPane.populate(rectanglePlot); } else { removeStackWholePane(); } } - if(radiusPane != null && plot instanceof VanChartRadiusPlot){ + if (radiusPane != null && plot instanceof VanChartRadiusPlot) { radiusPane.populateBean(plot); checkRadiusPane(plot); } @@ -306,17 +240,18 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP checkAreaSeriesFillColorPane(plot.getPlotStyle()); - checkCompsEnabledWithLarge(); + checkCompsEnabledWithLarge(plot); } /** * radius界面是否显示 + * * @param plot */ private void checkRadiusPane(Plot plot) { radiusPaneWithTitle.setVisible(true); - if (plot instanceof VanChartPlot){ - if (((VanChartPlot) plot).isInCustom()){ + if (plot instanceof VanChartPlot) { + if (((VanChartPlot) plot).isInCustom()) { radiusPaneWithTitle.setVisible(false); } } @@ -326,7 +261,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP * 保存 系列界面的属性到Plot */ public void updateBean(Plot plot) { - if(plot == null) { + if (plot == null) { return; } @@ -335,22 +270,18 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP super.updateBean(plot);//配色 - if(stylePane != null){//风格 + if (stylePane != null) {//风格 plot.setPlotStyle(stylePane.updateBean()); } - if(largeDataModelGroup != null){ - plot.setDataProcessor(largeDataModelGroup.getSelectedItem()); - } - - if(stackAndAxisEditPane != null && plot instanceof VanChartRectanglePlot){//堆积和坐标轴 - VanChartRectanglePlot rectanglePlot = (VanChartRectanglePlot)plot; - if(rectanglePlot.isCustomChart()){ + if (stackAndAxisEditPane != null && plot instanceof VanChartRectanglePlot) {//堆积和坐标轴 + VanChartRectanglePlot rectanglePlot = (VanChartRectanglePlot) plot; + if (rectanglePlot.isCustomChart()) { stackAndAxisEditPane.update(rectanglePlot); } } - if (radiusPane != null && plot instanceof VanChartRadiusPlot){ + if (radiusPane != null && plot instanceof VanChartRadiusPlot) { radiusPane.updateBean(plot); checkRadiusPane(plot); } @@ -360,47 +291,47 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP checkAreaSeriesFillColorPane(plot.getPlotStyle()); } - protected void checkoutMapType(Plot plot){ + protected void checkoutMapType(Plot plot) { } - protected void checkAreaSeriesFillColorPane(int plotStyle){ + protected void checkAreaSeriesFillColorPane(int plotStyle) { if (areaSeriesFillColorPane != null) { areaSeriesFillColorPane.checkoutAlpha(plotStyle == ChartConstants.STYLE_NONE); } } - protected void populateCondition(ConditionAttr defaultAttr){ - if(trendLinePane != null){//趋势线 - VanChartAttrTrendLine attrTrendLine =(VanChartAttrTrendLine)defaultAttr.getExisted(VanChartAttrTrendLine.class); + protected void populateCondition(ConditionAttr defaultAttr) { + if (trendLinePane != null) {//趋势线 + VanChartAttrTrendLine attrTrendLine = defaultAttr.getExisted(VanChartAttrTrendLine.class); trendLinePane.populate(attrTrendLine); } - if(lineTypePane != null){//线-线型、控制断开等 - VanChartAttrLine attrLine = (VanChartAttrLine)defaultAttr.getExisted(VanChartAttrLine.class); + if (lineTypePane != null) {//线-线型、控制断开等 + VanChartAttrLine attrLine = defaultAttr.getExisted(VanChartAttrLine.class); lineTypePane.populate(attrLine); } - if(markerPane != null){//标记点 - VanChartAttrMarker attrMarker = (VanChartAttrMarker)defaultAttr.getExisted(VanChartAttrMarker.class); + if (markerPane != null) {//标记点 + VanChartAttrMarker attrMarker = defaultAttr.getExisted(VanChartAttrMarker.class); markerPane.populate(attrMarker); } - if(areaSeriesFillColorPane != null){//填充颜色 - AttrAreaSeriesFillColorBackground seriesFillColorBackground = (AttrAreaSeriesFillColorBackground)defaultAttr.getExisted(AttrAreaSeriesFillColorBackground.class); + if (areaSeriesFillColorPane != null) {//填充颜色 + AttrAreaSeriesFillColorBackground seriesFillColorBackground = defaultAttr.getExisted(AttrAreaSeriesFillColorBackground.class); areaSeriesFillColorPane.populate(seriesFillColorBackground); } - if(borderPane != null){//边框 - AttrBorder attrBorder = (AttrBorder)defaultAttr.getExisted(AttrBorder.class); - if(attrBorder != null){ + if (borderPane != null) {//边框 + AttrBorder attrBorder = defaultAttr.getExisted(AttrBorder.class); + if (attrBorder != null) { borderPane.populate(attrBorder); } } populateAlpha(defaultAttr); } - protected void populateAlpha(ConditionAttr defaultAttr){ - if(transparent != null){//不透明度 - AttrAlpha attrAlpha = (AttrAlpha)defaultAttr.getExisted(AttrAlpha.class); - if(attrAlpha != null){ + protected void populateAlpha(ConditionAttr defaultAttr) { + if (transparent != null) {//不透明度 + AttrAlpha attrAlpha = defaultAttr.getExisted(AttrAlpha.class); + if (attrAlpha != null) { transparent.populateBean(attrAlpha.getAlpha() * VanChartAttrHelper.PERCENT); } else { //初始值为100 @@ -409,35 +340,35 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP } } - protected void updateCondition(ConditionAttr defaultAttr){ - if(trendLinePane != null){ + protected void updateCondition(ConditionAttr defaultAttr) { + if (trendLinePane != null) { VanChartAttrTrendLine newTrendLine = trendLinePane.update(); - VanChartAttrTrendLine attrTrendLine =(VanChartAttrTrendLine)defaultAttr.getExisted(VanChartAttrTrendLine.class); + VanChartAttrTrendLine attrTrendLine = defaultAttr.getExisted(VanChartAttrTrendLine.class); defaultAttr.remove(attrTrendLine); defaultAttr.addDataSeriesCondition(newTrendLine); } - if(lineTypePane != null){ - VanChartAttrLine attrLine = (VanChartAttrLine)defaultAttr.getExisted(VanChartAttrLine.class); + if (lineTypePane != null) { + VanChartAttrLine attrLine = defaultAttr.getExisted(VanChartAttrLine.class); defaultAttr.remove(attrLine); defaultAttr.addDataSeriesCondition(lineTypePane.update()); } - if(markerPane != null){ + if (markerPane != null) { VanChartAttrMarker newMarker = markerPane.update(); - VanChartAttrMarker attrMarker = (VanChartAttrMarker)defaultAttr.getExisted(VanChartAttrMarker.class); + VanChartAttrMarker attrMarker = defaultAttr.getExisted(VanChartAttrMarker.class); defaultAttr.remove(attrMarker); defaultAttr.addDataSeriesCondition(newMarker); } - if(areaSeriesFillColorPane != null){ + if (areaSeriesFillColorPane != null) { AttrAreaSeriesFillColorBackground newFillColorBackground = areaSeriesFillColorPane.update(); AttrAreaSeriesFillColorBackground oldFillColorBackground = defaultAttr.getExisted(AttrAreaSeriesFillColorBackground.class); - if(oldFillColorBackground != null){ + if (oldFillColorBackground != null) { defaultAttr.remove(oldFillColorBackground); } defaultAttr.addDataSeriesCondition(newFillColorBackground); } - if(borderPane != null){ - AttrBorder attrBorder = (AttrBorder)defaultAttr.getExisted(AttrBorder.class); - if(attrBorder == null){ + if (borderPane != null) { + AttrBorder attrBorder = defaultAttr.getExisted(AttrBorder.class); + if (attrBorder == null) { attrBorder = new AttrBorder(); defaultAttr.addDataSeriesCondition(attrBorder); } @@ -446,14 +377,14 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP updateAlpha(defaultAttr); } - protected void updateAlpha(ConditionAttr defaultAttr){ - if(transparent != null){ - AttrAlpha attrAlpha = (AttrAlpha)defaultAttr.getExisted(AttrAlpha.class); - if(attrAlpha == null){ + protected void updateAlpha(ConditionAttr defaultAttr) { + if (transparent != null) { + AttrAlpha attrAlpha = defaultAttr.getExisted(AttrAlpha.class); + if (attrAlpha == null) { attrAlpha = new AttrAlpha(); defaultAttr.addDataSeriesCondition(attrAlpha); } - attrAlpha.setAlpha((float)(transparent.updateBean()/VanChartAttrHelper.PERCENT)); + attrAlpha.setAlpha((float) (transparent.updateBean() / VanChartAttrHelper.PERCENT)); } } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java index b8550e0d42..deb285fc7f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java @@ -7,6 +7,7 @@ import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; import com.fr.chart.chartglyph.DataSheet; +import com.fr.chartx.attr.ZoomAttribute; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.MultilineLabel; @@ -17,7 +18,6 @@ import com.fr.js.NameJavaScriptGroup; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartTools; -import com.fr.plugin.chart.base.VanChartZoom; import com.fr.plugin.chart.vanchart.VanChart; import javax.swing.JPanel; @@ -116,7 +116,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane getPlotSeriesPane(ChartStylePane parent, Plot plot){ + public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { return new VanChartHeatMapSeriesPane(parent, plot); } - public ConditionAttributesPane getPlotConditionPane(Plot plot){ + public ConditionAttributesPane getPlotConditionPane(Plot plot) { return new VanChartHeatMapConditionPane(plot); } /** * 图表的属性界面数组 + * * @return 属性界面 */ - public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener){ + public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener) { VanChartStylePane stylePane = new VanChartMapStylePane(listener); - VanChartOtherPane otherPane = new VanChartOtherPane(){ + VanChartOtherPane otherPane = new VanChartOtherPane() { protected BasicBeanPane createInteractivePane() { - return new VanChartInteractivePaneWithMapZoom(); + return new VanChartInteractivePaneWithMapZoom() { + @Override + protected boolean isCurrentChartSupportLargeDataMode() { + return true; + } + }; } }; return new AbstractChartAttrPane[]{stylePane, otherPane}; diff --git a/designer-chart/src/main/java/com/fr/van/chart/line/VanChartLineSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/line/VanChartLineSeriesPane.java index 21d5b60d37..5f37e3563c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/line/VanChartLineSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/line/VanChartLineSeriesPane.java @@ -12,24 +12,23 @@ import java.awt.Component; /** * 折线图的系列界面 */ -public class VanChartLineSeriesPane extends VanChartAbstractPlotSeriesPane{ +public class VanChartLineSeriesPane extends VanChartAbstractPlotSeriesPane { private static final long serialVersionUID = 5595016643808487932L; - public VanChartLineSeriesPane(ChartStylePane parent, Plot plot){ + public VanChartLineSeriesPane(ChartStylePane parent, Plot plot) { super(parent, plot); } - protected JPanel getContentInPlotType(){ + protected JPanel getContentInPlotType() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] row = {p,p,p,p,p,p,p,p}; + double[] row = {p, p, p, p, p, p, p, p}; double[] col = {f}; Component[][] components = new Component[][]{ new Component[]{createLineTypePane()}, new Component[]{createMarkerPane()}, new Component[]{createStackedAndAxisPane()}, - new Component[]{createLargeDataModelPane()}, new Component[]{createTrendLinePane()}, }; diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java index df23244ccb..d9f5cc0e58 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java @@ -1,6 +1,5 @@ package com.fr.van.chart.map; -import com.fr.base.chart.chartdata.model.DataProcessor; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.design.gui.frpane.UINumberDragPane; @@ -12,7 +11,6 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.style.color.ColorSelectBox; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; - import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.base.AttrBorderWithAlpha; import com.fr.plugin.chart.base.AttrEffect; @@ -21,7 +19,6 @@ import com.fr.plugin.chart.base.VanChartAttrMarker; import com.fr.plugin.chart.bubble.attr.VanChartAttrBubble; import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot; import com.fr.plugin.chart.map.VanChartMapPlot; -import com.fr.plugin.chart.map.attr.AttrMapLabel; import com.fr.plugin.chart.map.line.condition.AttrCurve; import com.fr.plugin.chart.map.line.condition.AttrLineEffect; import com.fr.plugin.chart.type.MapMarkerType; @@ -79,7 +76,6 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { //line private VanChartCurvePane curvePane; private VanChartLineMapEffectPane lineMapEffectPane; - private UIButtonGroup lineMapLargeDataModelGroup;//大数据模式 private MapType mapType = MapType.AREA; @@ -87,53 +83,20 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { super(parent, plot); } - @Override - protected void checkLarge() { - if(largeModel()) { - if(plot instanceof VanChartMapPlot) { - ConditionAttr defaultAttr = plot.getConditionCollection().getDefaultAttr(); - AttrMapLabel attrMapLabel = defaultAttr.getExisted(AttrMapLabel.class); - if(attrMapLabel == null){ - attrMapLabel = new AttrMapLabel(); - defaultAttr.addDataSeriesCondition(attrMapLabel); - } - attrMapLabel.getPointLabel().setEnable(false); - - resetCustomCondition(((VanChartMapPlot) plot).getPointConditionCollection()); - } - } - - checkPointCompsEnabledWithLarge(); + protected void checkCompsEnabledWithLarge(Plot plot) { + checkPointCompsEnabledWithLarge(plot); + checkLineCompsEnabledWithLarge(plot); } - protected void checkCompsEnabledWithLarge() { - checkPointCompsEnabledWithLarge(); - checkLineCompsEnabledWithLarge(); - } - - private void checkPointCompsEnabledWithLarge() { - if(pointEffectPane != null) { - GUICoreUtils.setEnabled(pointEffectPane, !largeModel()); + private void checkPointCompsEnabledWithLarge(Plot plot) { + if (pointEffectPane != null) { + GUICoreUtils.setEnabled(pointEffectPane, !largeModel(plot)); } } - private boolean lineMapLargeModel() { - return lineMapLargeDataModelGroup != null && lineMapLargeDataModelGroup.getSelectedIndex() == 0; - } - - private void checkLineMapLarge() { - if(lineMapLargeModel()) { - if(plot instanceof VanChartMapPlot) { - resetCustomCondition(((VanChartMapPlot) plot).getLineConditionCollection()); - } - } - - checkLineCompsEnabledWithLarge(); - } - - private void checkLineCompsEnabledWithLarge() { - if(lineMapEffectPane != null) { - GUICoreUtils.setEnabled(lineMapEffectPane, !lineMapLargeModel()); + private void checkLineCompsEnabledWithLarge(Plot plot) { + if (lineMapEffectPane != null) { + GUICoreUtils.setEnabled(lineMapEffectPane, !largeModel(plot)); } } @@ -195,7 +158,6 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { Component[][] components = new Component[][]{ new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle((com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")), createPointAlphaPane())}, new Component[]{createMarkerComPane()}, - new Component[]{createLargeDataModelPane()}, new Component[]{createPointEffectPane()}, }; @@ -212,25 +174,12 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { Component[][] components = new Component[][]{ new Component[]{createCurvePane()}, - new Component[]{createLineMapLargeDataModelPane()}, new Component[]{createAnimationPane()} }; return TableLayoutHelper.createTableLayoutPane(components, row, col); } - private JPanel createLineMapLargeDataModelPane() { - lineMapLargeDataModelGroup = createLargeDataModelGroup(); - lineMapLargeDataModelGroup.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - checkLineMapLarge(); - } - }); - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Large_Model"), lineMapLargeDataModelGroup); - return createLargeDataModelPane(panel); - } - private Component createCurvePane() { curvePane = new VanChartCurvePane(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Curve"), curvePane); @@ -257,8 +206,8 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { commonMarkerPane = new VanChartMapScatterMarkerPane(); commonMarkerPane.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); - bubblePane = new VanChartBubblePane(){ - protected JPanel getContentPane () { + bubblePane = new VanChartBubblePane() { + protected JPanel getContentPane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; @@ -304,7 +253,7 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { JPanel pointPane = createPointPane(); JPanel linePane = createLinePane(); - JPanel panel = createGroupPane(plot, areaPane, pointPane, linePane); + JPanel panel = createGroupPane(plot, areaPane, pointPane, linePane); return panel; } @@ -313,7 +262,7 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { JPanel panel; if (ComparatorUtils.equals(plot.getClass(), VanChartDrillMapPlot.class)) { panel = createDrillMapCustomGroupPane(areaPane, pointPane); - }else { + } else { panel = createMapCustomGroupPane(areaPane, pointPane, linePane); } return panel; @@ -334,7 +283,7 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { public void stateChanged(ChangeEvent e) { if (areaPointAndLineGroup.getSelectedIndex() == 0) { cardLayout.show(centerPane, AREA_STRING); - } else if (areaPointAndLineGroup.getSelectedIndex() == 1){ + } else if (areaPointAndLineGroup.getSelectedIndex() == 1) { cardLayout.show(centerPane, POINT_STRING); } else { cardLayout.show(centerPane, LINE_STRING); @@ -375,36 +324,30 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { } public void populateBean(Plot plot) { - if(plot != null && plot instanceof VanChartMapPlot){ - if(markerTypeCom != null){ + if (plot != null && plot instanceof VanChartMapPlot) { + if (markerTypeCom != null) { markerTypeCom.setSelectedItem(((VanChartMapPlot) plot).getMapMarkerType().toLocalString()); } - if(nullValueColorBox != null){ + if (nullValueColorBox != null) { nullValueColorBox.setSelectObject(((VanChartMapPlot) plot).getNullValueColor()); } - if(lineMapLargeDataModelGroup != null){ - lineMapLargeDataModelGroup.setSelectedItem(((VanChartMapPlot) plot).getLineMapDataProcessor()); - } } super.populateBean(plot); } public void updateBean(Plot plot) { - if(plot != null && plot instanceof VanChartMapPlot){ - if(markerTypeCom != null){ + if (plot != null && plot instanceof VanChartMapPlot) { + if (markerTypeCom != null) { ((VanChartMapPlot) plot).setMapMarkerType(MapMarkerType.parseInt(markerTypeCom.getSelectedIndex())); } - if(nullValueColorBox != null){ + if (nullValueColorBox != null) { ((VanChartMapPlot) plot).setNullValueColor(nullValueColorBox.getSelectObject()); } - if(lineMapLargeDataModelGroup != null){ - ((VanChartMapPlot) plot).setLineMapDataProcessor(lineMapLargeDataModelGroup.getSelectedItem()); - } } super.updateBean(plot); } - @Override + @Override protected void populateCondition(ConditionAttr defaultAttr) { switch (mapType) { case AREA: @@ -427,50 +370,50 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { protected void populateArea(ConditionAttr defaultAttr) { populateAlpha(defaultAttr); if (borderWithAlphaPane != null) { - AttrBorderWithAlpha attrBorderWithAlpha = (AttrBorderWithAlpha) defaultAttr.getExisted(AttrBorderWithAlpha.class); + AttrBorderWithAlpha attrBorderWithAlpha = defaultAttr.getExisted(AttrBorderWithAlpha.class); borderWithAlphaPane.populate(attrBorderWithAlpha); } } private void populatePoint(ConditionAttr defaultAttr) { - if(pointAlphaPane != null){ - AttrMarkerAlpha attrAlpha = (AttrMarkerAlpha)defaultAttr.getExisted(AttrMarkerAlpha.class); + if (pointAlphaPane != null) { + AttrMarkerAlpha attrAlpha = defaultAttr.getExisted(AttrMarkerAlpha.class); double alpha = VanChartAttrHelper.PERCENT * (attrAlpha == null ? 1 : attrAlpha.getAlpha()); pointAlphaPane.populateBean(alpha); } - if(pointEffectPane != null){ + if (pointEffectPane != null) { AttrEffect attrEffect = defaultAttr.getExisted(AttrEffect.class); - if(attrEffect == null){//老的模板做界面上的兼容 + if (attrEffect == null) {//老的模板做界面上的兼容 attrEffect = new AttrEffect(3.2); attrEffect.setEnabled(false); } pointEffectPane.populateBean(attrEffect); } - VanChartAttrMarker attrMarker = (VanChartAttrMarker) defaultAttr.getExisted(VanChartAttrMarker.class); - if(commonMarkerPane != null) { + VanChartAttrMarker attrMarker = defaultAttr.getExisted(VanChartAttrMarker.class); + if (commonMarkerPane != null) { commonMarkerPane.populateBean(attrMarker); } - if(imageMarkerPane != null) { + if (imageMarkerPane != null) { imageMarkerPane.populateBean(attrMarker); } - if(bubblePane != null) { - VanChartAttrBubble attrBubble = (VanChartAttrBubble) defaultAttr.getExisted(VanChartAttrBubble.class); + if (bubblePane != null) { + VanChartAttrBubble attrBubble = defaultAttr.getExisted(VanChartAttrBubble.class); bubblePane.populateBean(attrBubble); } } private void populateLine(ConditionAttr defaultAttr) { - if (curvePane != null){ - if (defaultAttr.getExisted(AttrCurve.class) == null){ + if (curvePane != null) { + if (defaultAttr.getExisted(AttrCurve.class) == null) { defaultAttr.addDataSeriesCondition(new AttrCurve()); } - curvePane.populateBean((AttrCurve) defaultAttr.getExisted(AttrCurve.class)); + curvePane.populateBean(defaultAttr.getExisted(AttrCurve.class)); } - if (lineMapEffectPane != null){ - if (defaultAttr.getExisted(AttrLineEffect.class) == null){ + if (lineMapEffectPane != null) { + if (defaultAttr.getExisted(AttrLineEffect.class) == null) { defaultAttr.addDataSeriesCondition(new AttrLineEffect()); } AttrLineEffect attrLineEffect = defaultAttr.getExisted(AttrLineEffect.class); @@ -498,40 +441,40 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { } } - protected void checkoutMapType(Plot plot){ - this.mapType = ((VanChartMapPlot)plot).getMapType(); + protected void checkoutMapType(Plot plot) { + this.mapType = ((VanChartMapPlot) plot).getMapType(); } protected void updateArea(ConditionAttr defaultAttr) { updateAlpha(defaultAttr); if (borderWithAlphaPane != null) { - AttrBorderWithAlpha attrBorderWithAlpha = (AttrBorderWithAlpha) defaultAttr.getExisted(AttrBorderWithAlpha.class); + AttrBorderWithAlpha attrBorderWithAlpha = defaultAttr.getExisted(AttrBorderWithAlpha.class); defaultAttr.remove(attrBorderWithAlpha); defaultAttr.addDataSeriesCondition(borderWithAlphaPane.update()); } } private void updatePoint(ConditionAttr defaultAttr) { - if(pointAlphaPane != null){ - AttrMarkerAlpha attrAlpha = (AttrMarkerAlpha)defaultAttr.getExisted(AttrMarkerAlpha.class); - if(attrAlpha == null){ + if (pointAlphaPane != null) { + AttrMarkerAlpha attrAlpha = defaultAttr.getExisted(AttrMarkerAlpha.class); + if (attrAlpha == null) { attrAlpha = new AttrMarkerAlpha(); defaultAttr.addDataSeriesCondition(attrAlpha); } - attrAlpha.setAlpha((float)(pointAlphaPane.updateBean()/VanChartAttrHelper.PERCENT)); + attrAlpha.setAlpha((float) (pointAlphaPane.updateBean() / VanChartAttrHelper.PERCENT)); } - if(pointEffectPane != null){ + if (pointEffectPane != null) { AttrEffect attrEffect = defaultAttr.getExisted(AttrEffect.class); defaultAttr.remove(attrEffect); defaultAttr.addDataSeriesCondition(pointEffectPane.updateBean()); } - VanChartAttrMarker attrMarker = (VanChartAttrMarker) defaultAttr.getExisted(VanChartAttrMarker.class); + VanChartAttrMarker attrMarker = defaultAttr.getExisted(VanChartAttrMarker.class); defaultAttr.remove(attrMarker); - VanChartAttrBubble attrBubble = (VanChartAttrBubble) defaultAttr.getExisted(VanChartAttrBubble.class); + VanChartAttrBubble attrBubble = defaultAttr.getExisted(VanChartAttrBubble.class); defaultAttr.remove(attrBubble); - if(markerTypeCom != null) { + if (markerTypeCom != null) { if (markerTypeCom.getSelectedIndex() == 1) { defaultAttr.addDataSeriesCondition(commonMarkerPane.updateBean()); } else if (markerTypeCom.getSelectedIndex() == 2) { @@ -543,17 +486,17 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { } private void updateLine(ConditionAttr defaultAttr) { - if(curvePane != null){ + if (curvePane != null) { AttrCurve attrCurve = defaultAttr.getExisted(AttrCurve.class); - if(attrCurve != null){ + if (attrCurve != null) { defaultAttr.remove(AttrCurve.class); } attrCurve = curvePane.updateBean(); defaultAttr.addDataSeriesCondition(attrCurve); } - if (lineMapEffectPane != null){ + if (lineMapEffectPane != null) { AttrLineEffect attrLineEffect = defaultAttr.getExisted(AttrLineEffect.class); - if (attrLineEffect != null){ + if (attrLineEffect != null) { defaultAttr.remove(AttrLineEffect.class); } attrLineEffect = (AttrLineEffect) lineMapEffectPane.updateBean(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java index 2419604142..3eede87c3f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java @@ -1,12 +1,9 @@ package com.fr.van.chart.map.designer.other; import com.fr.chart.chartattr.Plot; - import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.type.MapType; -import com.fr.plugin.chart.vanchart.VanChart; -import com.fr.van.chart.designer.PlotFactory; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.other.AutoRefreshPane; import com.fr.van.chart.designer.other.AutoRefreshPaneWithoutTooltip; @@ -20,11 +17,13 @@ import javax.swing.JPanel; public class VanChartMapInteractivePane extends VanChartInteractivePaneWithMapZoom { private static final int HYPERLINK_LEFT_GAP = 36; private VanChartMapHyperLinkPane hyperlinkPane; + @Override protected JPanel createHyperlinkPane() { hyperlinkPane = new VanChartMapHyperLinkPane(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Insert_Hyperlink"), hyperlinkPane); } + @Override protected void populateHyperlink(Plot plot) { hyperlinkPane.populateBean(plot); @@ -36,26 +35,22 @@ public class VanChartMapInteractivePane extends VanChartInteractivePaneWithMapZo } @Override - protected boolean largeModel(Plot plot) { - if(plot instanceof VanChartMapPlot){ - VanChartMapPlot mapPlot = (VanChartMapPlot)plot; - switch (mapPlot.getMapType()){ - case LINE: - return PlotFactory.lineMapLargeModel(mapPlot); - default: - return PlotFactory.largeDataModel(mapPlot); - } + protected boolean isCurrentChartSupportLargeDataMode() { + if (this.chart == null || this.chart.getPlot() == null) { + return false; } - return false; + VanChartMapPlot mapPlot = this.chart.getPlot(); + + return mapPlot.getMapType() == MapType.POINT || mapPlot.getMapType() == MapType.LINE; } protected AutoRefreshPane getMoreLabelPane(VanChartPlot plot) { boolean isLargeModel = largeModel(plot); - VanChartMapPlot mapPlot = (VanChartMapPlot)plot; + VanChartMapPlot mapPlot = (VanChartMapPlot) plot; if (mapPlot.getMapType().equals(MapType.LINE)) { - return new AutoRefreshPaneWithoutTooltip((VanChart) chart, isLargeModel); + return new AutoRefreshPaneWithoutTooltip(chart, isLargeModel); } - return new AutoRefreshPane((VanChart) chart, isLargeModel); + return new AutoRefreshPane(chart, isLargeModel); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartLineMapConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartLineMapConditionPane.java index b6862a38e2..28e12ef1e5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartLineMapConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartLineMapConditionPane.java @@ -46,7 +46,7 @@ public class VanChartLineMapConditionPane extends DataSeriesConditionPane { classPaneMap.put(AttrFloatColor.class, new VanChartFloatColorConditionPane(this)); classPaneMap.put(AttrCurve.class, new VanChartCurveConditionPane(this)); classPaneMap.put(AttrTooltip.class, new VanChartLineMapTooltipConditionPane(this, plot)); - if(!PlotFactory.lineMapLargeModel(plot)){ + if (!PlotFactory.largeDataModel(plot)) { classPaneMap.put(AttrLineEffect.class, new VanChartLineEffectConditionPane(this, EffectHelper.getLineMapDefaultLineEffect())); } } @@ -56,6 +56,7 @@ public class VanChartLineMapConditionPane extends DataSeriesConditionPane { /** * 返回图表class对象 + * * @return class对象 */ public Class class4Correspond() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java index d6fe79390d..9b1aa395f5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java @@ -2,8 +2,14 @@ package com.fr.van.chart.multilayer; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chartx.AbstractVanSingleDataPane; +import com.fr.design.chartx.fields.diff.MultiPieCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.MultiPieDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; import com.fr.design.condition.ConditionAttributesPane; +import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.van.chart.multilayer.other.VanChartMultiPieConditionPane; @@ -36,15 +42,15 @@ public class MultiPieIndependentVanChartInterface extends AbstractIndependentVan }; } -// @Override -// public ChartDataPane getChartDataPane(AttributeChangeListener listener) { -// return new AbstractDataPane(listener) { -// @Override -// protected SingleDataPane createSingleDataPane() { -// return new SingleDataPane(new MultiPieDataSetFieldsPane(), new MultiPieCellDataFieldsPane()); -// } -// }; -// } + @Override + public ChartDataPane getChartDataPane(AttributeChangeListener listener) { + return new AbstractVanSingleDataPane(listener) { + @Override + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new MultiPieDataSetFieldsPane(), new MultiPieCellDataFieldsPane()); + } + }; + } public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ return new VanChartMultiPieSeriesPane(parent, plot); diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/ScatterIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/ScatterIndependentVanChartInterface.java index 263ce191af..7d3a7df481 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/ScatterIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/ScatterIndependentVanChartInterface.java @@ -4,6 +4,10 @@ package com.fr.van.chart.scatter; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chartx.AbstractVanSingleDataPane; +import com.fr.design.chartx.fields.diff.ScatterCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.ScatterDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -16,6 +20,7 @@ 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; +import com.fr.van.chart.designer.other.zoom.ZoomPane; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.scatter.component.VanChartScatterStylePane; import com.fr.van.chart.scatter.data.VanChartScatterPlotTableDataContentPane; @@ -56,18 +61,19 @@ public class ScatterIndependentVanChartInterface extends AbstractIndependentVanC public String getIconPath() { return "com/fr/design/images/form/toolbar/scatter.png"; } + @Override - public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ + public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { return new VanChartScatterSeriesPane(parent, plot); } @Override - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){ + public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { return new VanChartScatterPlotTableDataContentPane(parent); } @Override - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent){ + public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { return new BubblePlotReportDataContentPane(parent); } @@ -76,19 +82,39 @@ public class ScatterIndependentVanChartInterface extends AbstractIndependentVanC * 图表的属性界面数组 * @return 属性界面 */ - public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener){ + public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener) { VanChartStylePane stylePane = new VanChartScatterStylePane(listener); - VanChartOtherPane otherPane = new VanChartOtherPane(){ + VanChartOtherPane otherPane = new VanChartOtherPane() { @Override protected BasicBeanPane createInteractivePane() { - return new VanChartInteractivePaneWithOutSort(); + return new VanChartInteractivePaneWithOutSort() { + @Override + protected ZoomPane createZoomPane() { + return new ZoomPane(); + } + + @Override + protected boolean isCurrentChartSupportLargeDataMode() { + return true; + } + }; } }; return new AbstractChartAttrPane[]{stylePane, otherPane}; } - public ConditionAttributesPane getPlotConditionPane(Plot plot){ + public ConditionAttributesPane getPlotConditionPane(Plot plot) { return new VanChartScatterConditionPane(plot); } + + @Override + public ChartDataPane getChartDataPane(AttributeChangeListener listener) { + return new AbstractVanSingleDataPane(listener) { + @Override + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new ScatterDataSetFieldsPane(), new ScatterCellDataFieldsPane()); + } + }; + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java index 456c6a135d..e523a590d0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java @@ -5,7 +5,6 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; - import com.fr.van.chart.custom.component.VanChartCustomAxisConditionPane; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartLineTypePane; @@ -20,19 +19,19 @@ import java.awt.Component; /** * 散点图的系列界面 */ -public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane{ +public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane { private static final long serialVersionUID = 5595016643808487932L; - public VanChartScatterSeriesPane(ChartStylePane parent, Plot plot){ + public VanChartScatterSeriesPane(ChartStylePane parent, Plot plot) { super(parent, plot); } - protected JPanel getContentInPlotType(){ + protected JPanel getContentInPlotType() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] row = {p,p,p,p,p,p,p,p,p,p}; + double[] row = {p, p, p, p, p, p, p, p, p, p}; double[] col = {f}; Component[][] components = new Component[][]{ @@ -40,7 +39,6 @@ public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane{ new Component[]{createLineTypePane()}, new Component[]{createMarkerPane()}, new Component[]{createStackedAndAxisPane()}, - new Component[]{createLargeDataModelPane()}, new Component[]{createTrendLinePane()}, }; @@ -49,25 +47,25 @@ public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane{ } //设置色彩面板内容 - protected void setColorPaneContent (JPanel panel) { + protected void setColorPaneContent(JPanel panel) { panel.add(createAlphaPane(), BorderLayout.CENTER); } @Override //堆积和坐标轴设置(自定义柱形图等用到) protected JPanel createStackedAndAxisPane() { - stackAndAxisEditPane = new VanChartStackedAndAxisListControlPane(){ + stackAndAxisEditPane = new VanChartStackedAndAxisListControlPane() { @Override protected Class getStackAndAxisPaneClass() { return VanChartCustomAxisConditionPane.class; } @Override - public String getPaneTitle(){ + public String getPaneTitle() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Axis"); } }; - stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); + stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); return stackAndAxisEditExpandablePane; } @@ -77,8 +75,8 @@ public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane{ } @Override - protected void checkCompsEnabledWithLarge() { - super.checkCompsEnabledWithLarge(); + protected void checkCompsEnabledWithLarge(Plot plot) { + super.checkCompsEnabledWithLarge(this.plot); checkLinePane(); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterLineTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterLineTypePane.java index b9dac828c6..7ac507408b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterLineTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterLineTypePane.java @@ -1,16 +1,11 @@ package com.fr.van.chart.scatter.component; import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.TableLayoutHelper; - import com.fr.plugin.chart.base.VanChartAttrLine; import com.fr.plugin.chart.type.LineStyle; -import com.fr.stable.Constants; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.plugin.chart.type.LineType; import com.fr.van.chart.designer.component.VanChartLineTypePane; -import javax.swing.JPanel; import java.awt.Component; /** @@ -21,29 +16,22 @@ public class VanChartScatterLineTypePane extends VanChartLineTypePane { @Override protected void createLineStyle() { String[] textArray = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Normal_Line"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_CurveLine")}; + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_CurveLine")}; lineStyle = new UIButtonGroup(textArray, new LineStyle[]{LineStyle.NORMAL, LineStyle.CURVE}); } @Override - protected JPanel createContentPane(double p, double f) { - double[] row = {p,p,p}; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] col = {f, e}; - Component[][] components = new Component[][]{ - new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineWidth}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Present")), lineStyle}, + protected Component[][] createContentComponent(Component[] lineStyleComponent, Component[] nullValueBreakComponent) { + return new Component[][]{ + lineStyleComponent }; - - return TableLayoutHelper.createTableLayoutPane(components, row, col); } @Override protected VanChartAttrLine initVanChartAttrLine() { - VanChartAttrLine attrLine = new VanChartAttrLine(); + VanChartAttrLine attrLine = new VanChartAttrLine(); //默认为无线型,且默認空值不斷開 - attrLine.setLineWidth(Constants.LINE_NONE); + attrLine.setLineType(LineType.NONE); attrLine.setNullValueBreak(false); return attrLine; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/StructureIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/VanStructureChartTypeUI.java similarity index 81% rename from designer-chart/src/main/java/com/fr/van/chart/structure/desinger/StructureIndependentVanChartInterface.java rename to designer-chart/src/main/java/com/fr/van/chart/structure/desinger/VanStructureChartTypeUI.java index 6be8c692ba..19f5abd5a4 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/StructureIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/VanStructureChartTypeUI.java @@ -3,6 +3,10 @@ package com.fr.van.chart.structure.desinger; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chartx.AbstractVanSingleDataPane; +import com.fr.design.chartx.fields.diff.StructureCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.StructureDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -12,9 +16,10 @@ 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.plugin.chart.base.VanChartConstants; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; +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.structure.desinger.data.StructurePlotReportDataContentPane; import com.fr.van.chart.structure.desinger.data.StructurePlotTableDataContentPane; @@ -26,7 +31,7 @@ import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; /** * Created by shine on 2017/2/15. */ -public class StructureIndependentVanChartInterface extends AbstractIndependentVanChartUI { +public class VanStructureChartTypeUI extends AbstractIndependentVanChartUI { @Override public AbstractChartTypePane getPlotTypePane() { return new VanChartStructureTypePane(); @@ -84,16 +89,9 @@ public class StructureIndependentVanChartInterface extends AbstractIndependentVa return new VanChartInteractivePaneWithOutSort(){ @Override - protected String[] getNameArray() { - return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}; - + protected ZoomPane createZoomPane() { + return new ZoomPaneWithOutMode(); } - - @Override - protected String[] getValueArray() { - return new String[]{VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE}; - } - }; } }; @@ -105,8 +103,13 @@ public class StructureIndependentVanChartInterface extends AbstractIndependentVa return new VanChartStructureConditionPane(plot); } - /* @Override + @Override public ChartDataPane getChartDataPane(AttributeChangeListener listener) { - return new StructureChartDataPane(listener); - }*/ + return new AbstractVanSingleDataPane(listener) { + @Override + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new StructureDataSetFieldsPane(), new StructureCellDataFieldsPane()); + } + }; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractIndependentVanChartUI.java b/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractIndependentVanChartUI.java index e1234c90fe..39e22492f4 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractIndependentVanChartUI.java +++ b/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractIndependentVanChartUI.java @@ -2,6 +2,10 @@ package com.fr.van.chart.vanchart; import com.fr.chart.chartattr.Plot; import com.fr.design.chart.fun.impl.AbstractIndependentChartUIWithAPILevel; +import com.fr.design.chartx.AbstractVanSingleDataPane; +import com.fr.design.chartx.fields.diff.SingleCategoryCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.SingleCategoryDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; @@ -46,4 +50,14 @@ public abstract class AbstractIndependentVanChartUI extends AbstractIndependentC public int currentAPILevel() { return CURRENT_API_LEVEL; } + + @Override + public ChartDataPane getChartDataPane(AttributeChangeListener listener) { + return new AbstractVanSingleDataPane(listener) { + @Override + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new SingleCategoryDataSetFieldsPane(), new SingleCategoryCellDataFieldsPane()); + } + }; + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java b/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java index 9dfac7c2c1..6cd2743fef 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java +++ b/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java @@ -1,6 +1,14 @@ package com.fr.van.chart.vanchart; +import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chartx.AbstractVanSingleDataPane; +import com.fr.design.chartx.fields.diff.MultiCategoryCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.MultiCategoryDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.report.CategoryPlotReportDataContentPane; @@ -9,23 +17,61 @@ import com.fr.design.mainframe.chart.gui.data.table.CategoryPlotTableDataContent import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.van.chart.designer.data.VanChartMoreCateReportDataContentPane; import com.fr.van.chart.designer.data.VanChartMoreCateTableDataContentPane; +import com.fr.van.chart.designer.other.VanChartInteractivePane; +import com.fr.van.chart.designer.other.VanChartOtherPane; +import com.fr.van.chart.designer.other.zoom.ZoomPane; +import com.fr.van.chart.designer.style.VanChartStylePane; /** * Created by mengao on 2017/7/6. */ -public abstract class AbstractMultiCategoryVanChartUI extends AbstractIndependentVanChartUI { - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){ +public abstract class AbstractMultiCategoryVanChartUI extends AbstractIndependentVanChartUI { + public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { //自定义组合图特殊处理 - if (((VanChartPlot)plot).isInCustom() && ((VanChartPlot)plot).getCustomType().equals("CUSTOM")) { + if (((VanChartPlot) plot).isInCustom() && ((VanChartPlot) plot).getCustomType().equals("CUSTOM")) { return new CategoryPlotTableDataContentPane(parent); } - return new VanChartMoreCateTableDataContentPane(parent); } + return new VanChartMoreCateTableDataContentPane(parent); + } - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent){ + public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { //自定义组合图特殊处理 - if (((VanChartPlot)plot).isInCustom() && ((VanChartPlot)plot).getCustomType().equals("CUSTOM")) { + if (((VanChartPlot) plot).isInCustom() && ((VanChartPlot) plot).getCustomType().equals("CUSTOM")) { return new CategoryPlotReportDataContentPane(parent); } return new VanChartMoreCateReportDataContentPane(parent); } + + @Override + public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener) { + + VanChartStylePane stylePane = new VanChartStylePane(listener); + VanChartOtherPane otherPane = new VanChartOtherPane() { + @Override + protected BasicBeanPane createInteractivePane() { + return new VanChartInteractivePane() { + @Override + protected ZoomPane createZoomPane() { + return new ZoomPane(); + } + + @Override + protected boolean isCurrentChartSupportLargeDataMode() { + return true; + } + }; + } + }; + return new AbstractChartAttrPane[]{stylePane, otherPane}; + } + + @Override + public ChartDataPane getChartDataPane(AttributeChangeListener listener) { + return new AbstractVanSingleDataPane(listener) { + @Override + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane()); + } + }; + } } 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 62356028fc..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 @@ -3,18 +3,28 @@ package com.fr.van.chart.wordcloud.designer; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chartx.AbstractVanSingleDataPane; +import com.fr.design.chartx.fields.diff.WordCloudCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.WordCloudDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.AttributeChangeListener; 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.plugin.chart.base.VanChartConstants; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; +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; @@ -57,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); @@ -83,14 +103,8 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa return new VanChartInteractivePaneWithOutSort(){ @Override - protected String[] getNameArray() { - return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}; - } - - @Override - protected String[] getValueArray() { - return new String[]{VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE}; - + protected ZoomPane createZoomPane() { + return new ZoomPaneWithOutMode(); } }; } @@ -98,13 +112,13 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa return new AbstractChartAttrPane[]{stylePane, otherPane}; } -// @Override -// public ChartDataPane getChartDataPane(AttributeChangeListener listener) { -// return new AbstractDataPane(listener) { -// @Override -// protected SingleDataPane createSingleDataPane() { -// return new SingleDataPane(new WordCloudDataSetFieldsPane(), new WordCloudCellDataFieldsPane()); -// } -// }; -// } + @Override + public ChartDataPane getChartDataPane(AttributeChangeListener listener) { + return new AbstractVanSingleDataPane(listener) { + @Override + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new WordCloudDataSetFieldsPane(), new WordCloudCellDataFieldsPane()); + } + }; + } } 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/XCardAddButton.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardAddButton.java index a25ca05046..7f43c57dfa 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardAddButton.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardAddButton.java @@ -92,6 +92,9 @@ public class XCardAddButton extends XButton { if(cardLayout == null && tagLayout ==null ){ initRelateLayout(); } + if (cardLayout == null) { + throw new IllegalArgumentException("cardLayout can not be null"); + } int index = cardLayout.toData().getWidgetCount(); //添加新的tab,并将原来的设为未选中状态 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/layout/FRTitleLayout.java b/designer-form/src/main/java/com/fr/design/form/layout/FRTitleLayout.java index 413cbf2421..0ba996258a 100644 --- a/designer-form/src/main/java/com/fr/design/form/layout/FRTitleLayout.java +++ b/designer-form/src/main/java/com/fr/design/form/layout/FRTitleLayout.java @@ -126,11 +126,13 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{ int titleH = title==null ? 0 : WTitleLayout.TITLE_HEIGHT; for (int i=0; i< target.getComponentCount(); i++) { Component comp = target.getComponent(i); - if (comp == title) { - comp.setBounds(0, 0, width, WTitleLayout.TITLE_HEIGHT); - } else if (comp == body) { - int y = titleH+gap; - comp.setBounds(0, y, width, height-y); + if (comp != null) { + if (comp == title) { + comp.setBounds(0, 0, width, WTitleLayout.TITLE_HEIGHT); + } else if (comp == body) { + int y = titleH + gap; + comp.setBounds(0, y, width, height-y); + } } } } 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/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 3c03ba38d7..07cb7f93a3 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -573,8 +573,8 @@ public class EditingMouseListener extends MouseInputAdapter { GUICoreUtils.showPopupMenu(cellPopupMenu, designer, e.getX(), e.getY()); } } + creator.doLayout(); } - creator.doLayout(); LayoutUtils.layoutRootContainer(designer.getRootComponent()); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index 3ed29d0475..1a53a02105 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -242,6 +242,7 @@ public class FormCreatorDropTarget extends DropTarget { */ @Override public synchronized void dropActionChanged(DropTargetDragEvent dtde) { + //do nothing } /** 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 25c8a493e3..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; @@ -30,6 +31,7 @@ import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLableReader; import com.fr.third.javax.xml.stream.XMLStreamException; +import com.sun.management.OperatingSystemMXBean; import java.io.BufferedWriter; import java.io.ByteArrayInputStream; @@ -43,11 +45,14 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; +import java.lang.management.ManagementFactory; +import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; +import java.util.Objects; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -58,309 +63,340 @@ import java.util.concurrent.TimeUnit; */ public class InformationCollector implements XMLReadable, XMLWriter { - // 24小时上传一次 - private static final long DELTA = 24 * 3600 * 1000L; - private static final long SEND_DELAY = 300 * 1000L; - private static final String FILE_NAME = "fr.info"; - private static final String XML_START_STOP_LIST = "StartStopList"; - private static final String XML_START_STOP = "StartStop"; - private static final String XML_LAST_TIME = "LastTime"; - private static final String ATTR_START = "start"; - private static final String ATTR_STOP = "stop"; - private static final String XML_JAR = "JarInfo"; - private static final String XML_VERSION = "Version"; - private static final String XML_USERNAME = "Username"; - private static final String XML_UUID = "UUID"; - private static final String XML_KEY = "ActiveKey"; - private static final String XML_OS = "OS"; - - private static InformationCollector collector; - - //启动时间与关闭时间列表 - private List startStop = new ArrayList(); - //上一次的发送时间 - private String lastTime; - private StartStopTime current = new StartStopTime(); - - public static InformationCollector getInstance() { - if (collector == null) { - collector = new InformationCollector(); - - readEncodeXMLFile(collector, collector.getInfoFile()); - } - - return collector; - } - - private static void readEncodeXMLFile(XMLReadable xmlReadable, File xmlFile) { - if (xmlFile == null || !xmlFile.exists()) { - return; - } - String charset = EncodeConstants.ENCODING_UTF_8; - try { - String decodeContent = getDecodeFileContent(xmlFile); - InputStream xmlInputStream = new ByteArrayInputStream(decodeContent.getBytes(charset)); - InputStreamReader inputStreamReader = new InputStreamReader(xmlInputStream, charset); - - XMLableReader xmlReader = XMLableReader.createXMLableReader(inputStreamReader); - - if (xmlReader != null) { - xmlReader.readXMLObject(xmlReadable); - } - xmlInputStream.close(); - } catch (FileNotFoundException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } catch (XMLStreamException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - - } - - private static String getDecodeFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException { - InputStream encodeInputStream = new FileInputStream(xmlFile); - String encodeContent = IOUtils.inputStream2String(encodeInputStream); - return DesUtils.getDecString(encodeContent); - } - - private long getLastTimeMillis() { - if (StringUtils.isEmpty(this.lastTime)) { - return 0; - } - - try { - return DateUtils.string2Date(this.lastTime, true).getTime(); - } catch (Exception e) { - return -1; - } - - } - - private JSONObject getJSONContentAsByte() { - JSONObject content = new JSONObject(); - - JSONArray startStopArray = new JSONArray(); - for (int i = 0; i < startStop.size(); i++) { - JSONObject jo = new JSONObject(); - jo.put(ATTR_START, startStop.get(i).getStartDate()); - jo.put(ATTR_STOP, startStop.get(i).getStopDate()); - startStopArray.put(jo); - DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - content.put(XML_START_STOP, startStopArray); - content.put(XML_UUID, envManager.getUUID()); - content.put(XML_JAR, GeneralUtils.readBuildNO()); - content.put(XML_VERSION, ProductConstants.RELEASE_VERSION); - content.put(XML_USERNAME, MarketConfig.getInstance().getBbsUsername()); - content.put(XML_KEY, envManager.getActivationKey()); - content.put(XML_OS, System.getProperty("os.name")); - } - return content; - } - - private void sendUserInfo() { - long currentTime = new Date().getTime(); - long lastTime = getLastTimeMillis(); - - if (currentTime - lastTime <= DELTA) { - return; - } - JSONObject content = getJSONContentAsByte(); - String url = CloudCenter.getInstance().acquireUrlByKind("user.info.v10"); - boolean success = false; - try { - HashMap para = new HashMap<>(); - para.put("token", SiteCenterToken.generateToken()); - para.put("content", content); - String res = HttpToolbox.post(url, para); - success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - if (success) { - this.reset(); - } - } - - /** - * 收集开始使用时间,发送信息 - */ - public void collectStartTime() { - this.current.setStartDate(dateToString()); - - sendUserInfoInOtherThread(); - } - - private void sendUserInfoInOtherThread() { - if (!DesignerEnvManager.getEnvManager().isJoinProductImprove() || !FRContext.isChineseEnv()) { - return; - } - - ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("InformationCollector")); - service.schedule(new Runnable() { - @Override - public void run() { - sendUserInfo(); - FocusPointMessageUploader.getInstance().sendToCloudCenter(); - TemplateInfoCollector.getInstance().sendTemplateInfo(); - ErrorInfoUploader.getInstance().sendErrorInfo(); - } - }, SEND_DELAY, TimeUnit.MILLISECONDS); - } - - /** - * 收集结束使用时间 - */ - public void collectStopTime() { - this.current.setStopDate(dateToString()); - } - - private String dateToString() { - DateFormat df = FRContext.getDefaultValues().getDateTimeFormat(); - return df.format(new Date()); - } - - private void reset() { - this.startStop.clear(); - this.lastTime = dateToString(); - } - - private File getInfoFile() { - return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME)); - } - - /** - * 保存xml文件 - */ - public void saveXMLFile() { - File xmlFile = this.getInfoFile(); - try { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - XMLTools.writeOutputStreamXML(this, out); - out.flush(); - out.close(); - String fileContent = new String(out.toByteArray(), EncodeConstants.ENCODING_UTF_8); - String encodeCotent = DesUtils.getEncString(fileContent); - writeEncodeContentToFile(encodeCotent, xmlFile); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - - - /** - * 将文件内容写到输出流中 - */ - private static void writeEncodeContentToFile(String fileContent, File file) { - try (FileOutputStream fos = new FileOutputStream(file); - OutputStreamWriter osw = new OutputStreamWriter(fos, EncodeConstants.ENCODING_UTF_8); - BufferedWriter bw = new BufferedWriter(osw)) { - bw.write(fileContent); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - - @Override - public void writeXML(XMLPrintWriter writer) { - startStop.add(current); - writer.startTAG("Info"); - //启停信息 - writeStartStopList(writer); - //上一次更新的时间 - writeTag(XML_LAST_TIME, this.lastTime, writer); - - writer.end(); - } - - private void writeStartStopList(XMLPrintWriter writer) { - //启停 - writer.startTAG(XML_START_STOP_LIST); - for (int i = 0; i < startStop.size(); i++) { - startStop.get(i).writeXML(writer); - } - writer.end(); - } - - private void writeTag(String tag, String content, XMLPrintWriter writer) { - if (StringUtils.isEmpty(content)) { - return; - } - - writer.startTAG(tag); - writer.textNode(content); - writer.end(); - } - - @Override - public void readXML(XMLableReader reader) { - if (reader.isChildNode()) { - String name = reader.getTagName(); - if (XML_START_STOP_LIST.equals(name)) { - readStartStopList(reader); - } else if (XML_LAST_TIME.equals(name)) { - readLastTime(reader); - } - } - } - - private void readLastTime(XMLableReader reader) { - String tmpVal; - if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) { - this.lastTime = tmpVal; - } - } - - private void readStartStopList(XMLableReader reader) { - startStop.clear(); - - reader.readXMLObject(new XMLReadable() { - public void readXML(XMLableReader reader) { - if (XML_START_STOP.equals(reader.getTagName())) { - StartStopTime startStopTime = new StartStopTime(); - reader.readXMLObject(startStopTime); - startStop.add(startStopTime); - } - } - }); - } - - private class StartStopTime implements XMLReadable, XMLWriter { - - private String startDate; - private String stopDate; - - public String getStartDate() { - return startDate; - } - - public void setStartDate(String startDate) { - this.startDate = startDate; - } - - public String getStopDate() { - return stopDate; - } - - public void setStopDate(String endDate) { - this.stopDate = endDate; - } - - public void writeXML(XMLPrintWriter writer) { - writer.startTAG(XML_START_STOP); - if (StringUtils.isNotEmpty(startDate)) { - writer.attr(ATTR_START, this.startDate); - } - if (StringUtils.isNotEmpty(stopDate)) { - writer.attr(ATTR_STOP, this.stopDate); - } - writer.end(); - } - - public void readXML(XMLableReader reader) { - this.startDate = reader.getAttrAsString(ATTR_START, StringUtils.EMPTY); - this.stopDate = reader.getAttrAsString(ATTR_STOP, StringUtils.EMPTY); - } - - } + /** + * 24小时上传一次 + */ + private static final long DELTA = 24 * 3600 * 1000L; + private static final long SEND_DELAY = 300 * 1000L; + private static final int BYTE_TO_MB = 1024 * 1024; + private static final String FILE_NAME = "fr.info"; + private static final String XML_START_STOP_LIST = "StartStopList"; + private static final String XML_START_STOP = "StartStop"; + private static final String XML_LAST_TIME = "LastTime"; + private static final String ATTR_START = "start"; + private static final String ATTR_STOP = "stop"; + private static final String XML_JAR = "JarInfo"; + private static final String XML_VERSION = "Version"; + private static final String XML_USERNAME = "Username"; + private static final String XML_UUID = "UUID"; + private static final String XML_KEY = "ActiveKey"; + private static final String XML_OS = "OS"; + private static final String XML_ARCH = "arch"; + private static final String XML_AVAILABLE_PROCESSORS = "cpu"; + private static final String XML_PHYSICAL_MEMORY = "systemMemory"; + + private static InformationCollector collector; + + /** + * 启动时间与关闭时间列表 + */ + private List startStop = new ArrayList(); + + /** + * 上一次的发送时间 + */ + private String lastTime; + private StartStopTime current = new StartStopTime(); + + public static InformationCollector getInstance() { + if (collector == null) { + collector = new InformationCollector(); + + readEncodeXMLFile(collector, collector.getInfoFile()); + } + + return collector; + } + + private static void readEncodeXMLFile(XMLReadable xmlReadable, File xmlFile) { + if (xmlFile == null || !xmlFile.exists()) { + return; + } + String charset = EncodeConstants.ENCODING_UTF_8; + try { + String decodeContent = getDecodeFileContent(xmlFile); + InputStream xmlInputStream = new ByteArrayInputStream(decodeContent.getBytes(charset)); + InputStreamReader inputStreamReader = new InputStreamReader(xmlInputStream, charset); + + XMLableReader xmlReader = XMLableReader.createXMLableReader(inputStreamReader); + + if (xmlReader != null) { + xmlReader.readXMLObject(xmlReadable); + } + xmlInputStream.close(); + } catch (FileNotFoundException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } catch (XMLStreamException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + + } + + private static String getDecodeFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException { + InputStream encodeInputStream = new FileInputStream(xmlFile); + String encodeContent = IOUtils.inputStream2String(encodeInputStream); + return DesUtils.getDecString(encodeContent); + } + + private long getLastTimeMillis() { + if (StringUtils.isEmpty(this.lastTime)) { + return 0; + } + + try { + return Objects.requireNonNull(DateUtils.string2Date(this.lastTime, true)).getTime(); + } catch (Exception e) { + return -1; + } + + } + + private JSONObject getJSONContentAsByte() { + JSONObject content = new JSONObject(); + + JSONArray startStopArray = new JSONArray(); + for (StartStopTime startStopTime : startStop) { + JSONObject jo = new JSONObject(); + jo.put(ATTR_START, startStopTime.getStartDate()); + jo.put(ATTR_STOP, startStopTime.getStopDate()); + startStopArray.put(jo); + } + DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); + content.put(XML_START_STOP, startStopArray); + content.put(XML_UUID, envManager.getUUID()); + content.put(XML_JAR, GeneralUtils.readBuildNO()); + content.put(XML_VERSION, ProductConstants.RELEASE_VERSION); + content.put(XML_USERNAME, MarketConfig.getInstance().getBbsUsername()); + content.put(XML_KEY, envManager.getActivationKey()); + content.put(XML_OS, System.getProperty("os.name")); + content.put(XML_ARCH, System.getProperty("os.arch")); + content.put(XML_AVAILABLE_PROCESSORS, Runtime.getRuntime().availableProcessors()); + content.put(XML_PHYSICAL_MEMORY, getTotalPhysicalMemorySize()); + return content; + } + + /** + * 获取物理内存,单位GB + * + * @return 物理内存 + */ + private static long getTotalPhysicalMemorySize() { + OperatingSystemMXBean bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); + return bean.getTotalPhysicalMemorySize() / BYTE_TO_MB; + } + + + private void sendUserInfo() { + long currentTime = System.currentTimeMillis(); + long lastTime = getLastTimeMillis(); + + if (currentTime - lastTime <= DELTA) { + return; + } + JSONObject content = getJSONContentAsByte(); + String url = CloudCenter.getInstance().acquireUrlByKind("user.info.v10"); + boolean success = false; + try { + HashMap para = new HashMap<>(); + para.put("token", SiteCenterToken.generateToken()); + para.put("content", content); + String res = HttpToolbox.post(url, para); + success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + if (success) { + this.reset(); + } + } + + /** + * 收集开始使用时间,发送信息 + */ + public void collectStartTime() { + this.current.setStartDate(dateToString()); + + sendUserInfoInOtherThread(); + } + + private void sendUserInfoInOtherThread() { + if (!DesignerEnvManager.getEnvManager().isJoinProductImprove() || !FRContext.isChineseEnv()) { + return; + } + + ScheduledExecutorService service = Executors + .newSingleThreadScheduledExecutor(new NamedThreadFactory("InformationCollector")); + service.schedule(new Runnable() { + @Override + public void run() { + SolidCollector.getInstance().sendToCloudCenterAndDeleteFile(); + sendUserInfo(); + FocusPointMessageUploader.getInstance().sendToCloudCenter(); + TemplateInfoCollector.getInstance().sendTemplateInfo(); + ErrorInfoUploader.getInstance().sendErrorInfo(); + } + }, SEND_DELAY, TimeUnit.MILLISECONDS); + service.shutdown(); + } + + /** + * 收集结束使用时间 + */ + public void collectStopTime() { + this.current.setStopDate(dateToString()); + } + + private String dateToString() { + DateFormat df = FRContext.getDefaultValues().getDateTimeFormat(); + return df.format(new Date()); + } + + private void reset() { + this.startStop.clear(); + this.lastTime = dateToString(); + } + + private File getInfoFile() { + return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME)); + } + + /** + * 保存xml文件 + */ + public void saveXMLFile() { + File xmlFile = this.getInfoFile(); + try { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + XMLTools.writeOutputStreamXML(this, out); + out.flush(); + out.close(); + String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8); + String encodeCotent = DesUtils.getEncString(fileContent); + writeEncodeContentToFile(encodeCotent, xmlFile); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + + /** + * 将文件内容写到输出流中 + */ + private static void writeEncodeContentToFile(String fileContent, File file) { + try (FileOutputStream fos = new FileOutputStream(file); + OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8); + BufferedWriter bw = new BufferedWriter(osw)) { + bw.write(fileContent); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + startStop.add(current); + writer.startTAG("Info"); + //启停信息 + writeStartStopList(writer); + //上一次更新的时间 + writeTag(XML_LAST_TIME, this.lastTime, writer); + + writer.end(); + } + + private void writeStartStopList(XMLPrintWriter writer) { + //启停 + writer.startTAG(XML_START_STOP_LIST); + for (StartStopTime startStopTime : startStop) { + startStopTime.writeXML(writer); + } + writer.end(); + } + + private void writeTag(String tag, String content, XMLPrintWriter writer) { + if (StringUtils.isEmpty(content)) { + return; + } + + writer.startTAG(tag); + writer.textNode(content); + writer.end(); + } + + @Override + public void readXML(XMLableReader reader) { + if (reader.isChildNode()) { + String name = reader.getTagName(); + if (XML_START_STOP_LIST.equals(name)) { + readStartStopList(reader); + } else if (XML_LAST_TIME.equals(name)) { + readLastTime(reader); + } + } + } + + private void readLastTime(XMLableReader reader) { + String tmpVal; + if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) { + this.lastTime = tmpVal; + } + } + + private void readStartStopList(XMLableReader reader) { + startStop.clear(); + + reader.readXMLObject(new XMLReadable() { + @Override + public void readXML(XMLableReader reader) { + if (XML_START_STOP.equals(reader.getTagName())) { + StartStopTime startStopTime = new StartStopTime(); + reader.readXMLObject(startStopTime); + startStop.add(startStopTime); + } + } + }); + } + + private class StartStopTime implements XMLReadable, XMLWriter { + + private String startDate; + private String stopDate; + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getStopDate() { + return stopDate; + } + + public void setStopDate(String endDate) { + this.stopDate = endDate; + } + + @Override + public void writeXML(XMLPrintWriter writer) { + writer.startTAG(XML_START_STOP); + if (StringUtils.isNotEmpty(startDate)) { + writer.attr(ATTR_START, this.startDate); + } + if (StringUtils.isNotEmpty(stopDate)) { + writer.attr(ATTR_STOP, this.stopDate); + } + writer.end(); + } + + @Override + public void readXML(XMLableReader reader) { + this.startDate = reader.getAttrAsString(ATTR_START, StringUtils.EMPTY); + this.stopDate = reader.getAttrAsString(ATTR_STOP, StringUtils.EMPTY); + } + + } } \ No newline at end of file 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/bbs/UserInfoLabel.java b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java index 7fe8b8ff87..6e423e1729 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java @@ -16,6 +16,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.upm.event.CertificateEvent; import com.fr.design.utils.concurrent.ThreadFactoryBuilder; import com.fr.design.utils.gui.GUICoreUtils; @@ -28,10 +29,8 @@ import com.fr.general.DateUtils; import com.fr.general.http.HttpClient; import com.fr.log.FineLoggerFactory; import com.fr.stable.EncodeConstants; -import com.fr.stable.OperatingSystem; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; - import javax.swing.SwingConstants; import java.awt.Cursor; import java.awt.Desktop; @@ -142,7 +141,8 @@ public class UserInfoLabel extends UILabel { @Override public void run() { // vito:最新mac10.12和javafx弹出框初始化时会有大几率卡死在native方法,这里先屏蔽一下。 - if (!FRContext.isChineseEnv() || OperatingSystem.isMacOS()) { + //ARM下暂时也不能用javafx + if (!SupportOSImpl.BBSDIALOG.support()) { return; } String lastBBSNewsTime = DesignerEnvManager.getEnvManager().getLastShowBBSNewsTime(); 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/mainframe/messagecollect/StartupMessageCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java index ac10724668..0ca2eb95ba 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java @@ -8,6 +8,7 @@ import com.fr.event.EventDispatcher; import com.fr.event.Listener; import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralUtils; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; @@ -30,14 +31,15 @@ public class StartupMessageCollector { private static final String XML_STARTUP_TIME = "t"; private static final String XML_STARTUP_LOG = "startupLog"; - private static final String XML_STARTUP_Memory = "designerMemory"; + private static final String XML_STARTUP_MEMORY = "designerMemory"; private static final String XML_STARTUP_COST = "cost"; private static final String XML_UUID = "UUID"; + private static final String XML_BUILD_NO = "buildNO"; private static final String STARTUP_URL_KEY = "user.info.v10.startup"; private static final String LOG_TYPE = "single"; private static final int BYTE_TO_MB = 1024 * 1024; - public static final StartupMessageCollector INSTANCE = new StartupMessageCollector(); + private static final StartupMessageCollector INSTANCE = new StartupMessageCollector(); private StartupMessageCollector() { } @@ -67,10 +69,11 @@ public class StartupMessageCollector { } JSONObject json = JSONObject.create() .put(XML_UUID, DesignerEnvManager.getEnvManager().getUUID()) + .put(XML_BUILD_NO, GeneralUtils.readBuildNO()) .put(XML_STARTUP_TIME, FineRuntime.getAppStartTime() + FineRuntime.getStartingTime()) .put(XML_STARTUP_COST, FineRuntime.getStartingTime()) .put(XML_STARTUP_LOG, profile) - .put(XML_STARTUP_Memory, Runtime.getRuntime().totalMemory() / BYTE_TO_MB); + .put(XML_STARTUP_MEMORY, Runtime.getRuntime().maxMemory() / BYTE_TO_MB); sendInfo(json, url + LOG_TYPE); } }); 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/grid/GridUI.java b/designer-realize/src/main/java/com/fr/grid/GridUI.java index 0ccff309f6..0f13b8d0ab 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUI.java @@ -1209,7 +1209,7 @@ public class GridUI extends ComponentUI { * @return 有效返回true */ public static boolean validate(Rectangle2D rect) { - return rect != null && rect.getX() != INVALID_INTEGER; + return rect != null && !ComparatorUtils.equals(rect.getX(), INVALID_INTEGER); } @@ -1268,4 +1268,4 @@ public class GridUI extends ComponentUI { paginateLineList.add(new Line2D.Double(0, sumHeight, width, sumHeight)); } } -} \ No newline at end of file +} diff --git a/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java b/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java index 89509b9942..4529465c7a 100644 --- a/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java +++ b/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java @@ -141,7 +141,7 @@ class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader { ImageFrame imageFrame = loader.load(i, w, h, preserveRatio, smooth); images[i] = convert(imageFrame); synchronized (this) { - this.notify(); + notifyAll(); } } } catch (ImageStorageException e) { diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 822a332f35..1727906fb0 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -8,6 +8,7 @@ import com.fr.base.passport.FinePassportManager; import com.fr.base.process.ProcessOperator; import com.fr.chart.chartattr.ChartCollection; import com.fr.config.MarketConfig; +import com.fr.decision.update.backup.RecoverManager; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.NewFormAction; @@ -54,9 +55,11 @@ import com.fr.design.mainframe.form.FormReportComponentComposite; import com.fr.design.mainframe.loghandler.DesignerLogAppender; import com.fr.design.mainframe.socketio.DesignerSocketIO; import com.fr.design.module.DesignModuleFactory; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.parameter.FormParameterReader; import com.fr.design.parameter.ParameterPropertyPane; import com.fr.design.parameter.WorkBookParameterReader; +import com.fr.design.update.actions.RecoverForDesigner; import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane; import com.fr.form.stable.ElementCaseThumbnailProcessor; import com.fr.general.xml.GeneralXMLTools; @@ -91,6 +94,8 @@ import com.fr.report.cell.painter.CellImagePainter; import com.fr.stable.ArrayUtils; import com.fr.stable.ParameterProvider; import com.fr.stable.bridge.StableFactory; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; import com.fr.stable.plugin.ExtraDesignClassManagerProvider; import com.fr.stable.script.CalculatorProviderContext; import com.fr.stable.script.ValueConverter; @@ -125,9 +130,15 @@ public class DesignerActivator extends Activator { designerModuleStart(); loadLogAppender(); DesignerSocketIO.update(); - UserInfoPane.getInstance().updateBBSUserInfo(); + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + UserInfoPane.getInstance().updateBBSUserInfo(); + } + }, SupportOSImpl.USERINFOPANE); storePassport(); AlphaFineHelper.switchConfig4Locale(); + RecoverManager.register(new RecoverForDesigner()); } @Override diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java index ee57bb551b..7d63571ad6 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java @@ -5,8 +5,10 @@ import com.fr.design.EnvChangeEntrance; import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; +import com.fr.stable.StringUtils; import com.fr.value.NotNullLazyValue; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; @@ -19,6 +21,8 @@ import org.jetbrains.annotations.NotNull; */ public class DesignerWorkspaceProvider extends Activator { + private static final String SPECIFY_WORKSPACE = "fr.designer.workspace"; + private NotNullLazyValue startupArgs = new NotNullLazyValue() { @NotNull @Override @@ -37,7 +41,13 @@ public class DesignerWorkspaceProvider extends Activator { } else { try { String current = DesignerEnvManager.getEnvManager().getCurEnvName(); - DesignerWorkspaceInfo workspaceInfo = DesignerEnvManager.getEnvManager().getWorkspaceInfo(current); + String workspacePath; + DesignerWorkspaceInfo workspaceInfo; + if (StringUtils.isNotEmpty(workspacePath = System.getProperty(SPECIFY_WORKSPACE))) { + workspaceInfo = LocalDesignerWorkspaceInfo.create(StringUtils.EMPTY, workspacePath); + } else { + workspaceInfo = DesignerEnvManager.getEnvManager().getWorkspaceInfo(current); + } Workspace workspace = DesignerWorkspaceGenerator.generate(workspaceInfo); boolean checkValid = workspace != null && workspaceInfo.checkValid(); if (!checkValid) { 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"));