From 80279fe9539c4dc8012a9a13062aec1abe22a45b Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 16 Oct 2018 10:53:58 +0800 Subject: [PATCH 01/11] =?UTF-8?q?REPORT-11690=20=E3=80=90=E9=9B=86?= =?UTF-8?q?=E7=BE=A4=E3=80=91=E3=80=90=E8=BF=9C=E7=A8=8B=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E3=80=91=E6=B7=BB=E5=8A=A0=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tabledatapane/DBTableDataPane.java | 682 +++++++++--------- 1 file changed, 349 insertions(+), 333 deletions(-) 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 37ba914661..d441d51160 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 @@ -1,7 +1,6 @@ package com.fr.design.data.tabledata.tabledatapane; import com.fr.base.BaseUtils; -import com.fr.base.FRContext; import com.fr.base.Parameter; import com.fr.base.ParameterHelper; import com.fr.data.core.db.TableProcedure; @@ -35,17 +34,25 @@ import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ToolBarDef; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; - import com.fr.general.sql.SqlUtils; +import com.fr.log.FineLoggerFactory; import com.fr.script.Calculator; import com.fr.stable.ArrayUtils; import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JToolBar; import javax.swing.text.BadLocationException; import javax.swing.text.Document; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; @@ -53,334 +60,343 @@ import java.util.ArrayList; import java.util.List; public class DBTableDataPane extends AbstractTableDataPane { - private static final int BOTTOM = 6; - private static final String PREVIEW_BUTTON = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"); + private static final int BOTTOM = 6; + private static final String PREVIEW_BUTTON = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"); private static final String REFRESH_BUTTON = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh"); - private ConnectionTableProcedurePane connectionTableProcedurePane; - private UITableEditorPane editorPane; - - private DBTableDataMenuHandler dbTableDataMenuHandler; - private SQLEditPane sqlTextPane; - private UICheckBox isShareCheckBox; - private MaxMemRowCountPanel maxPanel; - private String pageQuery = null; - private DBTableData dbTableData; - - private void init() { - this.setLayout(new BorderLayout(4, 4)); - - sqlTextPane = new SQLEditPane(); - sqlTextPane.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL); - - ParameterTableModel model = new ParameterTableModel() { - @Override - public UITableEditAction[] createAction() { - return (UITableEditAction[]) ArrayUtils.add(super.createDBTableAction(), new RefreshAction()); - } - }; - editorPane = new UITableEditorPane(model); - - // 左边的Panel,上面是选择DatabaseConnection的ComboBox,下面DatabaseConnection对应的Table - connectionTableProcedurePane = new ConnectionTableProcedurePane() { - @Override - protected void filter(Connection connection, String conName, List nameList) { - connection.addConnection(nameList, conName, new Class[]{JDBCDatabaseConnection.class, JNDIDatabaseConnection.class}); - } - }; - connectionTableProcedurePane.addDoubleClickListener(new DoubleClickSelectedNodeOnTreeListener() { - - @Override - public void actionPerformed(TableProcedure target) { - Document document = sqlTextPane.getDocument(); - try { - document.insertString(sqlTextPane.getCaretPosition(), target.toString(), null); - } catch (BadLocationException e) { - FRContext.getLogger().error(e.getMessage(), e); - } - // 这里开始作色,本来可以给sqlTextPane添加DocumentListener来实现的, - // 后来发现insertString的时候,锁定了JTextPane,不能调用setXXX来作色,先这样了. -// sqlTextPane.syntaxTexts(); - sqlTextPane.requestFocus(); - } - }); - sqlTextPane.addFocusListener(new FocusListener() { - public void focusGained(FocusEvent e) { - // unsupport - } - - public void focusLost(FocusEvent e) { - if (isPreviewOrRefreshButton(e)) { - checkParameter(); - } - } - }); - } - - - private void initMainSplitPane() { - Box box = new Box(BoxLayout.Y_AXIS); - - - JPanel northPane = new JPanel(new BorderLayout(4, 4)); - JToolBar editToolBar = createToolBar(); - northPane.add(editToolBar, BorderLayout.CENTER); - northPane.setBorder(BorderFactory.createEmptyBorder(0, 0, BOTTOM, 0)); - - RTextScrollPane sqlTextScrollPane = new RTextScrollPane(sqlTextPane); - sqlTextScrollPane.setLineNumbersEnabled(true); - sqlTextScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); - sqlTextScrollPane.setPreferredSize(new Dimension(680, 600)); - - JPanel paraMeanPane = new JPanel(new BorderLayout()); - paraMeanPane.setPreferredSize(new Dimension(680, 90)); - UILabel paraMean = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Param_DES")); - paraMeanPane.add(paraMean, BorderLayout.CENTER); - - - box.add(northPane); - box.add(sqlTextScrollPane); - box.add(paraMeanPane); - box.add(editorPane); - - JPanel sqlSplitPane = new JPanel(new BorderLayout(4, 4)); - sqlSplitPane.add(box, BorderLayout.CENTER); - - - box.setMinimumSize(new Dimension(310, 400)); - // 使用SplitPane - JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, connectionTableProcedurePane, sqlSplitPane); - mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); - mainSplitPane.setOneTouchExpandable(true); - this.add(mainSplitPane, BorderLayout.CENTER); - } - - public DBTableDataPane() { - init(); - initMainSplitPane(); - } - - - - private boolean isPreviewOrRefreshButton (FocusEvent e) { - if (e.getOppositeComponent() != null) { - String name = e.getOppositeComponent().getName(); - return ComparatorUtils.equals(name, PREVIEW_BUTTON) || ComparatorUtils.equals(name, REFRESH_BUTTON); - } - return false; - } - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS-Database_Query"); - } - - private void refresh() { - String[] paramTexts = new String[2]; - paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText()); - paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery); - List existParameterList = editorPane.update(); - Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); - - editorPane.populate(ParameterHelper.analyzeAndUnionSameParameters(paramTexts, ps)); - } - - private JToolBar createToolBar() { - // p:工具栏. - ToolBarDef toolBarDef = new ToolBarDef(); - toolBarDef.addShortCut(new PreviewAction()); - toolBarDef.addShortCut(SeparatorDef.DEFAULT); - toolBarDef.addShortCut(new EditPageQueryAction()); - dbTableDataMenuHandler = ExtraDesignClassManager.getInstance().getSingle(DBTableDataMenuHandler.MARK_STRING); - if (dbTableDataMenuHandler != null) { - toolBarDef.addShortCut(SeparatorDef.DEFAULT); - toolBarDef.addShortCut(dbTableDataMenuHandler.createQueryAction()); - } - isShareCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Is_Share_DBTableData")); - isShareCheckBox.setBackground(Color.WHITE); - maxPanel = new MaxMemRowCountPanel(); - maxPanel.setBorder(null); - UIToolbar editToolBar = ToolBarDef.createJToolBar(); - toolBarDef.updateToolBar(editToolBar); - editToolBar.add(isShareCheckBox); - editToolBar.add(maxPanel); - return editToolBar; - } - - private void checkParameter() { - String[] paramTexts = new String[2]; - paramTexts[0] = sqlTextPane.getText(); - paramTexts[1] = pageQuery; - Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false); - - if (parameters.length < 1 && editorPane.update().size() < 1) { - return; - } - boolean isIn = true; - List list = editorPane.update(); - List name = new ArrayList(); - for (int i = 0; i < list.size(); i++) { - name.add(list.get(i).getName()); - } - for (int i = 0; i < parameters.length; i++) { - if (!name.contains(parameters[i].getName())) { - isIn = false; - break; - } - } - if (list.size() == parameters.length && isIn) { - return; - } - // bug:34175 删了是否刷新对话框, 均直接刷新 - refresh(); - } - - @Override - public void populateBean(DBTableData dbtabledata) { - this.dbTableData = dbtabledata; - if (dbTableDataMenuHandler != null) { - dbTableDataMenuHandler.populate(dbtabledata); - } - ParameterProvider[] parameters = null; - - Calculator c = Calculator.createCalculator(); - - parameters = dbtabledata.getParameters(c); - editorPane.populate(parameters); - - com.fr.data.impl.Connection db = null; - String query = null; - boolean isShare = false; - int maxMemeryRow = -1; - - db = dbtabledata.getDatabase(); - query = dbtabledata.getQuery(); - isShare = dbtabledata.isShare(); - maxMemeryRow = dbtabledata.getMaxMemRowCount(); - this.pageQuery = dbtabledata.getPageQuerySql(); - this.connectionTableProcedurePane.setSelectedDatabaseConnection(db); - this.sqlTextPane.setText(query); - this.sqlTextPane.requestFocus(); - this.sqlTextPane.moveCaretPosition(this.sqlTextPane.getCaretPosition()); - - isShareCheckBox.setSelected(isShare); - maxPanel.setValue(maxMemeryRow); - } - - @Override - public DBTableData updateBean() { - String dbName = this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName(); - if (StringUtils.isBlank(dbName) || StringUtils.isBlank(this.sqlTextPane.getText())) { - try { - throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + "."); - } catch (Exception e) { - // JOptionPane.showMessageDialog(DBTableDataPane.this, - // com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + "."); - } - } - - List parameterList = editorPane.update(); - Parameter[] parameters = parameterList.toArray(new Parameter[parameterList.size()]); - - dbTableData.setDatabase(new NameDatabaseConnection(dbName)); - - // p:必须先设置Parameters数组,因为setQuery里面会自动设置的 - - dbTableData.setParameters(parameters); - dbTableData.setQuery(this.sqlTextPane.getText()); - - dbTableData.setShare(isShareCheckBox.isSelected()); - dbTableData.setMaxMemRowCount(maxPanel.getValue()); - dbTableData.setPageQuerySql(this.pageQuery); - if (dbTableDataMenuHandler != null) { - dbTableDataMenuHandler.update(); - } - return dbTableData; - } - - protected class RefreshAction extends UITableEditAction { - public RefreshAction() { - this.setName(REFRESH_BUTTON); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); - } - - public void actionPerformed(ActionEvent e) { - refresh(); - } - - @Override - public void checkEnabled() { - // unsupport - } - } - - private class PreviewAction extends UpdateAction { - public PreviewAction() { - this.setName(PREVIEW_BUTTON); - this.setMnemonic('P'); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); - } - - public void actionPerformed(ActionEvent evt) { - checkParameter(); - PreviewTablePane.previewTableData(DBTableDataPane.this.updateBean()); - } - } - - private class EditPageQueryAction extends UpdateAction { - public EditPageQueryAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Page_Query")); - this.setMnemonic('L'); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png")); - } - - public void actionPerformed(ActionEvent e) { - final QueryPane pane = new QueryPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Define_Page_Query_SQL")); - pane.populate(pageQuery); - BasicDialog dialog = pane.showWindow(DesignerContext.getDesignerFrame()); - dialog.addDialogActionListener(new DialogActionAdapter() { - public void doOk() { - pageQuery = pane.update(); - checkParameter(); - } - }); - dialog.setVisible(true); - } - } - - private class QueryPane extends BasicPane { - private SQLEditPane pageQueryPane; - private String title; - - public QueryPane(String title) { - this.title = title; - this.initComponents(); - } - - public void initComponents() { - this.setLayout(new BorderLayout()); - pageQueryPane = new SQLEditPane(); - this.add(new JScrollPane(pageQueryPane)); - } - - public void populate(String text) { - if (StringUtils.isBlank(text)) { - return; - } - pageQueryPane.setText(text); - } - - public String update() { - String text = pageQueryPane.getText(); - if (StringUtils.isBlank(text)) { - return null; - } else { - return text; - } - } - - @Override - protected String title4PopupWindow() { - return title; - } - } + private ConnectionTableProcedurePane connectionTableProcedurePane; + private UITableEditorPane editorPane; + + private DBTableDataMenuHandler dbTableDataMenuHandler; + private SQLEditPane sqlTextPane; + private UICheckBox isShareCheckBox; + private MaxMemRowCountPanel maxPanel; + private String pageQuery = null; + private DBTableData dbTableData; + + private void init() { + this.setLayout(new BorderLayout(4, 4)); + + sqlTextPane = new SQLEditPane(); + sqlTextPane.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL); + + ParameterTableModel model = new ParameterTableModel() { + @Override + public UITableEditAction[] createAction() { + return ArrayUtils.add(super.createDBTableAction(), new RefreshAction()); + } + }; + editorPane = new UITableEditorPane(model); + + // 左边的Panel,上面是选择DatabaseConnection的ComboBox,下面DatabaseConnection对应的Table + connectionTableProcedurePane = new ConnectionTableProcedurePane() { + @Override + protected void filter(Connection connection, String conName, List nameList) { + + connection.addConnection(nameList, conName, new Class[]{JDBCDatabaseConnection.class, JNDIDatabaseConnection.class}); + } + }; + connectionTableProcedurePane.addDoubleClickListener(new DoubleClickSelectedNodeOnTreeListener() { + + @Override + public void actionPerformed(TableProcedure target) { + Document document = sqlTextPane.getDocument(); + try { + document.insertString(sqlTextPane.getCaretPosition(), target.toString(), null); + } catch (BadLocationException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + // 这里开始作色,本来可以给sqlTextPane添加DocumentListener来实现的, + // 后来发现insertString的时候,锁定了JTextPane,不能调用setXXX来作色,先这样了. + // sqlTextPane.syntaxTexts(); + sqlTextPane.requestFocus(); + } + }); + sqlTextPane.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + // do nothing + } + + @Override + public void focusLost(FocusEvent e) { + if (isPreviewOrRefreshButton(e)) { + checkParameter(); + } + } + }); + } + + + private void initMainSplitPane() { + Box box = new Box(BoxLayout.Y_AXIS); + + + JPanel northPane = new JPanel(new BorderLayout(4, 4)); + JToolBar editToolBar = createToolBar(); + northPane.add(editToolBar, BorderLayout.CENTER); + northPane.setBorder(BorderFactory.createEmptyBorder(0, 0, BOTTOM, 0)); + + RTextScrollPane sqlTextScrollPane = new RTextScrollPane(sqlTextPane); + sqlTextScrollPane.setLineNumbersEnabled(true); + sqlTextScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); + sqlTextScrollPane.setPreferredSize(new Dimension(680, 600)); + + JPanel paraMeanPane = new JPanel(new BorderLayout()); + paraMeanPane.setPreferredSize(new Dimension(680, 90)); + UILabel paraMean = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Param_DES")); + paraMeanPane.add(paraMean, BorderLayout.CENTER); + + + box.add(northPane); + box.add(sqlTextScrollPane); + box.add(paraMeanPane); + box.add(editorPane); + + JPanel sqlSplitPane = new JPanel(new BorderLayout(4, 4)); + sqlSplitPane.add(box, BorderLayout.CENTER); + + + box.setMinimumSize(new Dimension(300, 400)); + // 防止数据连接名过长时影响 split pane 分割效果 + connectionTableProcedurePane.setMinimumSize(new Dimension(250, 400)); + connectionTableProcedurePane.setMaximumSize(new Dimension(500, 400)); + // 使用SplitPane + JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, connectionTableProcedurePane, sqlSplitPane); + mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); + mainSplitPane.setOneTouchExpandable(true); + this.add(mainSplitPane, BorderLayout.CENTER); + } + + public DBTableDataPane() { + init(); + initMainSplitPane(); + } + + + private boolean isPreviewOrRefreshButton(FocusEvent e) { + if (e.getOppositeComponent() != null) { + String name = e.getOppositeComponent().getName(); + return ComparatorUtils.equals(name, PREVIEW_BUTTON) || ComparatorUtils.equals(name, REFRESH_BUTTON); + } + return false; + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS-Database_Query"); + } + + private void refresh() { + String[] paramTexts = new String[2]; + paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText()); + paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery); + List existParameterList = editorPane.update(); + Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); + + editorPane.populate(ParameterHelper.analyzeAndUnionSameParameters(paramTexts, ps)); + } + + private JToolBar createToolBar() { + // p:工具栏. + ToolBarDef toolBarDef = new ToolBarDef(); + toolBarDef.addShortCut(new PreviewAction()); + toolBarDef.addShortCut(SeparatorDef.DEFAULT); + toolBarDef.addShortCut(new EditPageQueryAction()); + dbTableDataMenuHandler = ExtraDesignClassManager.getInstance().getSingle(DBTableDataMenuHandler.MARK_STRING); + if (dbTableDataMenuHandler != null) { + toolBarDef.addShortCut(SeparatorDef.DEFAULT); + toolBarDef.addShortCut(dbTableDataMenuHandler.createQueryAction()); + } + isShareCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Is_Share_DBTableData")); + isShareCheckBox.setBackground(Color.WHITE); + maxPanel = new MaxMemRowCountPanel(); + maxPanel.setBorder(null); + UIToolbar editToolBar = ToolBarDef.createJToolBar(); + toolBarDef.updateToolBar(editToolBar); + editToolBar.add(isShareCheckBox); + editToolBar.add(maxPanel); + return editToolBar; + } + + private void checkParameter() { + String[] paramTexts = new String[2]; + paramTexts[0] = sqlTextPane.getText(); + paramTexts[1] = pageQuery; + Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false); + + if (parameters.length < 1 && editorPane.update().size() < 1) { + return; + } + boolean isIn = true; + List list = editorPane.update(); + List name = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + name.add(list.get(i).getName()); + } + for (int i = 0; i < parameters.length; i++) { + if (!name.contains(parameters[i].getName())) { + isIn = false; + break; + } + } + if (list.size() == parameters.length && isIn) { + return; + } + // bug:34175 删了是否刷新对话框, 均直接刷新 + refresh(); + } + + @Override + public void populateBean(DBTableData dbtabledata) { + this.dbTableData = dbtabledata; + if (dbTableDataMenuHandler != null) { + dbTableDataMenuHandler.populate(dbtabledata); + } + ParameterProvider[] parameters = null; + + Calculator c = Calculator.createCalculator(); + + parameters = dbtabledata.getParameters(c); + editorPane.populate(parameters); + + com.fr.data.impl.Connection db = null; + String query = null; + boolean isShare = false; + int maxMemeryRow = -1; + + db = dbtabledata.getDatabase(); + query = dbtabledata.getQuery(); + isShare = dbtabledata.isShare(); + maxMemeryRow = dbtabledata.getMaxMemRowCount(); + this.pageQuery = dbtabledata.getPageQuerySql(); + this.connectionTableProcedurePane.setSelectedDatabaseConnection(db); + this.sqlTextPane.setText(query); + this.sqlTextPane.requestFocus(); + this.sqlTextPane.moveCaretPosition(this.sqlTextPane.getCaretPosition()); + + isShareCheckBox.setSelected(isShare); + maxPanel.setValue(maxMemeryRow); + } + + @Override + public DBTableData updateBean() { + String dbName = this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName(); + if (StringUtils.isBlank(dbName) || StringUtils.isBlank(this.sqlTextPane.getText())) { + try { + throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + "."); + } catch (Exception ignore) { + // JOptionPane.showMessageDialog(DBTableDataPane.this, + // com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + "."); + } + } + + List parameterList = editorPane.update(); + Parameter[] parameters = parameterList.toArray(new Parameter[parameterList.size()]); + + dbTableData.setDatabase(new NameDatabaseConnection(dbName)); + + // p:必须先设置Parameters数组,因为setQuery里面会自动设置的 + + dbTableData.setParameters(parameters); + dbTableData.setQuery(this.sqlTextPane.getText()); + + dbTableData.setShare(isShareCheckBox.isSelected()); + dbTableData.setMaxMemRowCount(maxPanel.getValue()); + dbTableData.setPageQuerySql(this.pageQuery); + if (dbTableDataMenuHandler != null) { + dbTableDataMenuHandler.update(); + } + return dbTableData; + } + + protected class RefreshAction extends UITableEditAction { + public RefreshAction() { + this.setName(REFRESH_BUTTON); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); + } + + @Override + public void actionPerformed(ActionEvent e) { + refresh(); + } + + @Override + public void checkEnabled() { + // do nothing + } + } + + private class PreviewAction extends UpdateAction { + public PreviewAction() { + this.setName(PREVIEW_BUTTON); + this.setMnemonic('P'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); + } + + @Override + public void actionPerformed(ActionEvent evt) { + checkParameter(); + PreviewTablePane.previewTableData(DBTableDataPane.this.updateBean()); + } + } + + private class EditPageQueryAction extends UpdateAction { + public EditPageQueryAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Page_Query")); + this.setMnemonic('L'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png")); + } + + @Override + public void actionPerformed(ActionEvent e) { + final QueryPane pane = new QueryPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Define_Page_Query_SQL")); + pane.populate(pageQuery); + BasicDialog dialog = pane.showWindow(DesignerContext.getDesignerFrame()); + dialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + pageQuery = pane.update(); + checkParameter(); + } + }); + dialog.setVisible(true); + } + } + + private class QueryPane extends BasicPane { + private SQLEditPane pageQueryPane; + private String title; + + public QueryPane(String title) { + this.title = title; + this.initComponents(); + } + + public void initComponents() { + this.setLayout(new BorderLayout()); + pageQueryPane = new SQLEditPane(); + this.add(new JScrollPane(pageQueryPane)); + } + + public void populate(String text) { + if (StringUtils.isBlank(text)) { + return; + } + pageQueryPane.setText(text); + } + + public String update() { + String text = pageQueryPane.getText(); + if (StringUtils.isBlank(text)) { + return null; + } else { + return text; + } + } + + @Override + protected String title4PopupWindow() { + return title; + } + } } From 4d9e1fb8bc669f01c6b6e1dc448f5820f7f7cc50 Mon Sep 17 00:00:00 2001 From: zheng Date: Tue, 16 Oct 2018 11:57:48 +0800 Subject: [PATCH 02/11] =?UTF-8?q?CHART-3211=20=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E6=8F=92=E4=BB=B6=E6=9C=89=E4=BA=9B=E6=B2=A1?= =?UTF-8?q?=E6=9C=89type=20pane?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/ChartTypeInterfaceManager.java | 6 ++++++ .../chart/fun/impl/AbstractIndependentChartsUI.java | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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 5d54adff73..a01fc0ce58 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -61,6 +61,7 @@ import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.injectable.PluginSingleInjection; import com.fr.plugin.solution.closeable.CloseableContainedMap; import com.fr.stable.ArrayUtils; +import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.van.chart.area.AreaIndependentVanChartInterface; @@ -107,6 +108,8 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr private static Map idAndPriorityMap = new HashMap(); + public static final String TYPE_PANE_DEFAULT_TITLE = "DEFAULT_NAME"; + public synchronized static ChartTypeInterfaceManager getInstance() { return classManager; @@ -260,6 +263,9 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr String plotID = entry.getKey(); AbstractChartTypePane pane = entry.getValue().getPlotTypePane(); + if (AssistUtils.equals(pane.title4PopupWindow(), TYPE_PANE_DEFAULT_TITLE)) { + continue; + } pane.setPlotID(plotID); paneList.add(pane); diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java index 6e9ef2f03c..19244a3fdd 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java @@ -1,6 +1,7 @@ package com.fr.design.chart.fun.impl; import com.fr.chart.chartattr.Plot; +import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.chart.fun.IndependentChartUIProvider; import com.fr.design.condition.ConditionAttributesPane; @@ -40,7 +41,12 @@ public abstract class AbstractIndependentChartsUI extends AbstractProvider imple @Override public AbstractChartTypePane getPlotTypePane() { - return new PiePlotPane(); + return new PiePlotPane() { + @Override + public String title4PopupWindow() { + return ChartTypeInterfaceManager.TYPE_PANE_DEFAULT_TITLE; + } + }; } @Override From 06a9cf646bbcccb0543d4294b8c492e78a22ffa3 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 18 Oct 2018 14:11:18 +0800 Subject: [PATCH 03/11] =?UTF-8?q?REPORT-11950=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E5=86=85=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86=E4=B8=8E?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E5=86=85=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=9A=84=E6=8E=88=E6=9D=83=E5=AD=97=E6=A0=B7=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/extra/PluginUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java index ff4b44c216..92a8388647 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java @@ -230,7 +230,7 @@ public class PluginUtils { jo.put("licDamaged", pluginContext.isLicDamaged()); jo.put("available", pluginContext.isAvailable()); jo.put("leftDays", pluginContext.getLeftDays()); - jo.put("trial", pluginContext.isOnTrial()); + jo.put("onTrial", pluginContext.isOnTrial()); jo.put("deadline", getDeadline(pluginContext)); jo.put("registerFailed", pluginContext.isRegisterFailed()); ja.put(jo); From 7883dc1a6bccf4b83d16bc68a9692636d82694cd Mon Sep 17 00:00:00 2001 From: "Wim.Zhai" Date: Thu, 18 Oct 2018 15:13:34 +0800 Subject: [PATCH 04/11] =?UTF-8?q?CHART-3208=20=E7=BB=A7=E6=89=BF&=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E5=90=AB=E9=BB=98=E8=AE=A4=E5=80=BC=E2=80=9C=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E2=80=9D=E7=9A=84=E4=B8=8B=E6=8B=89=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java b/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java index 57960a47ba..7be740f4d8 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java @@ -10,7 +10,7 @@ import java.util.List; */ public class UIComboBoxWithNone extends UIComboBox { - private static String getNoneLocaleString() { + public String getNoneLocaleString() { return Toolkit.i18nText("Fine-Design_Chart_Use_None"); } From bfa56e2ba8f52c68480c92541b8da7a91f129c1e Mon Sep 17 00:00:00 2001 From: "Wim.Zhai" Date: Thu, 18 Oct 2018 15:26:17 +0800 Subject: [PATCH 05/11] change to protected method --- .../com/fr/extended/chart/UIComboBoxWithNone.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java b/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java index 7be740f4d8..77347e0fd8 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java @@ -10,25 +10,25 @@ import java.util.List; */ public class UIComboBoxWithNone extends UIComboBox { - public String getNoneLocaleString() { + protected String getDefaultLocaleString() { return Toolkit.i18nText("Fine-Design_Chart_Use_None"); } @Override public void refreshBoxItems(List list) { super.refreshBoxItems(list); - addNoneItem(); + addDefaultItem(); } @Override public void clearBoxItems() { super.clearBoxItems(); - addNoneItem(); + addDefaultItem(); } - private void addNoneItem() { - addItem(getNoneLocaleString()); + private void addDefaultItem() { + addItem(getDefaultLocaleString()); } @@ -37,7 +37,7 @@ public class UIComboBoxWithNone extends UIComboBox { super.setSelectedItem(anObject); if (getSelectedIndex() == -1) {//找不到的都选中无。中文的无 英文下是none。 - super.setSelectedItem(getNoneLocaleString()); + super.setSelectedItem(getDefaultLocaleString()); } } From 46283dc93c6423225ab4637f99942a72041a59b1 Mon Sep 17 00:00:00 2001 From: "alex.sung" Date: Mon, 22 Oct 2018 11:11:06 +0800 Subject: [PATCH 06/11] =?UTF-8?q?REPORT-11880=20SimilarSearchManeger?= =?UTF-8?q?=E6=8B=BC=E9=94=99=E4=BA=86....?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/alphafine/AlphaFineHelper.java | 4 ++-- .../mainframe/alphafine/cell/CellModelHelper.java | 4 ++-- .../mainframe/alphafine/component/AlphaFineDialog.java | 6 +++--- ...larSearchManeger.java => SimilarSearchManager.java} | 10 +++++----- .../search/manager/impl/SearchManegerTest.java | 10 +++++----- 5 files changed, 17 insertions(+), 17 deletions(-) rename designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/{SimilarSearchManeger.java => SimilarSearchManager.java} (92%) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index 93e60182c2..376d63f172 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -14,7 +14,7 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.HotIssuesManager; import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager; -import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManeger; +import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManager; import com.fr.general.ProcessCanceledException; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; @@ -142,7 +142,7 @@ public class AlphaFineHelper { result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"))); } else if (object instanceof PluginSearchManager) { result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); - } else if (object instanceof SimilarSearchManeger) { + } else if (object instanceof SimilarSearchManager) { result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Relation_Item"))); } else if (object instanceof HotIssuesManager) { return new SearchResult(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java index 83ab319a6b..c545cefaac 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java @@ -6,7 +6,7 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.ActionSearchManager import com.fr.design.mainframe.alphafine.search.manager.impl.DocumentSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager; -import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManeger; +import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManager; import com.fr.json.JSONObject; /** @@ -34,7 +34,7 @@ public class CellModelHelper { break; case ROBOT: case RECOMMEND_ROBOT: - cellModel = SimilarSearchManeger.getModelFromCloud(object.optJSONObject(RESULT)); + cellModel = SimilarSearchManager.getModelFromCloud(object.optJSONObject(RESULT)); break; } return cellModel; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index 5d0b2aff0d..6310a22331 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -32,7 +32,7 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.SegmentationManager; -import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManeger; +import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManager; import com.fr.design.mainframe.errorinfo.ErrorInfoUploader; import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; import com.fr.form.main.Form; @@ -573,7 +573,7 @@ public class AlphaFineDialog extends UIDialog { } private void buildSimilarList(final String[] searchText) { - addSearchResult(SimilarSearchManeger.getInstance().getLessSearchResult(searchText)); + addSearchResult(SimilarSearchManager.getInstance().getLessSearchResult(searchText)); } private synchronized void addSearchResult(SearchResult searchResult) { @@ -1052,7 +1052,7 @@ public class AlphaFineDialog extends UIDialog { break; case ROBOT: case RECOMMEND_ROBOT: - moreResult = SimilarSearchManeger.getInstance().getMoreSearchResult(searchTextField.getText()); + moreResult = SimilarSearchManager.getInstance().getMoreSearchResult(searchTextField.getText()); break; case RECOMMEND: moreResult = RecommendSearchManager.getInstance().getMoreSearchResult(searchTextField.getText()); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java similarity index 92% rename from designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java rename to designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java index b1da3d72b1..1754b1284b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java @@ -17,16 +17,16 @@ import com.fr.third.org.apache.commons.codec.digest.DigestUtils; /** * Created by alex.sung on 2018/8/3. */ -public class SimilarSearchManeger implements AlphaFineSearchProvider { - private static volatile SimilarSearchManeger instance; +public class SimilarSearchManager implements AlphaFineSearchProvider { + private static volatile SimilarSearchManager instance; private SearchResult lessModelList; private SearchResult moreModelList = new SearchResult(); - public static SimilarSearchManeger getInstance() { + public static SimilarSearchManager getInstance() { if (instance == null) { - synchronized (SimilarSearchManeger.class) { + synchronized (SimilarSearchManager.class) { if (instance == null) { - instance = new SimilarSearchManeger(); + instance = new SimilarSearchManager(); } } } diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java index e09be0cfb9..1b6236f98e 100644 --- a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java +++ b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java @@ -9,7 +9,7 @@ import org.junit.Before; import org.junit.Test; public class SearchManegerTest { - SimilarSearchManeger similarSearchManeger; + SimilarSearchManager similarSearchManager; ComplementAdviceManager complementAdviceManager; DocumentSearchManager documentSearchManager; PluginSearchManager pluginSearchManager; @@ -23,7 +23,7 @@ public class SearchManegerTest { public void setUp() { recentSearchManager = RecentSearchManager.getInstance(); recommendSearchManager = RecommendSearchManager.getInstance(); - similarSearchManeger = SimilarSearchManeger.getInstance(); + similarSearchManager = SimilarSearchManager.getInstance(); complementAdviceManager = ComplementAdviceManager.getInstance(); documentSearchManager = DocumentSearchManager.getInstance(); pluginSearchManager = PluginSearchManager.getInstance(); @@ -43,7 +43,7 @@ public class SearchManegerTest { lessModelList = recentSearchManager.getLessSearchResult(new String[]{"数据集"}); Assert.assertNotNull(lessModelList); - lessModelList = similarSearchManeger.getLessSearchResult(new String[]{"数据集"}); + lessModelList = similarSearchManager.getLessSearchResult(new String[]{"数据集"}); Assert.assertEquals(lessModelList.get(1).getType(), CellType.ROBOT); lessModelList = complementAdviceManager.getAllSearchResult(new String[]{"数据集"}); @@ -51,7 +51,7 @@ public class SearchManegerTest { //返回MoreSearchResult SearchResult moreModelList; - moreModelList = similarSearchManeger.getMoreSearchResult("数据集"); + moreModelList = similarSearchManager.getMoreSearchResult("数据集"); Assert.assertNotNull(moreModelList); moreModelList = recommendSearchManager.getMoreSearchResult("数据集"); @@ -60,7 +60,7 @@ public class SearchManegerTest { @Test public void getModelFromCloudTest() { - Assert.assertNotNull(SimilarSearchManeger.getModelFromCloud(new JSONObject())); + Assert.assertNotNull(SimilarSearchManager.getModelFromCloud(new JSONObject())); Assert.assertNotNull(DocumentSearchManager.getModelFromCloud(new JSONObject())); Assert.assertNotNull(PluginSearchManager.getModelFromCloud(new JSONObject())); } From 45bfd042154f2cbae33462a18a7ff61cd52febf1 Mon Sep 17 00:00:00 2001 From: "Mata.Li" Date: Mon, 22 Oct 2018 16:49:31 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20findbug?= =?UTF-8?q?s=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../onlineupdate/domain/UpdateConstants.java | 16 +++++---- .../ui/dialog/RestoreResultDialog.java | 5 +-- .../ui/dialog/UpdateMainDialog.java | 36 +++++++++---------- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/onlineupdate/domain/UpdateConstants.java b/designer-base/src/main/java/com/fr/design/onlineupdate/domain/UpdateConstants.java index c132dcc03f..853b8576e6 100644 --- a/designer-base/src/main/java/com/fr/design/onlineupdate/domain/UpdateConstants.java +++ b/designer-base/src/main/java/com/fr/design/onlineupdate/domain/UpdateConstants.java @@ -4,7 +4,11 @@ package com.fr.design.onlineupdate.domain; * Created by XINZAI on 2018/8/21. */ +import com.fr.third.org.apache.commons.collections4.collection.UnmodifiableCollection; +import com.fr.third.org.apache.commons.collections4.list.UnmodifiableList; + import java.awt.Color; +import java.util.Arrays; /** * 更新升级的常量 @@ -28,7 +32,7 @@ public interface UpdateConstants { int BYTE = 153600; - String[] JARS_FOR_SERVER_X = new String[]{ + UnmodifiableList JARS_FOR_SERVER_X = new UnmodifiableList(Arrays.asList(new String[]{ "fine-activator-10.0.jar", "fine-core-10.0.jar", "fine-report-engine-10.0.jar", @@ -41,16 +45,16 @@ public interface UpdateConstants { "fine-datasource-10.0.jar", "fine-third-10.0.jar", "fine-accumulator-10.0.jar" - }; + })); - String[] JARS_FOR_DESIGNER_X = new String[]{ + UnmodifiableList JARS_FOR_DESIGNER_X = new UnmodifiableList(Arrays.asList(new String[]{ "fine-report-designer-10.0.jar", "aspectjrt.jar" - }; + })); - String[] LOG_TYPE = new String[]{ + UnmodifiableList LOG_TYPE = new 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/onlineupdate/ui/dialog/RestoreResultDialog.java b/designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/RestoreResultDialog.java index 787a88ea87..680d3190dc 100644 --- a/designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/RestoreResultDialog.java +++ b/designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/RestoreResultDialog.java @@ -27,6 +27,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -161,7 +162,7 @@ public class RestoreResultDialog extends JDialog { } private void putJarBackupFilesToInstallLib(String installHome, Map map, java.util.List list) { - String[] files = UpdateConstants.JARS_FOR_DESIGNER_X; + List files = UpdateConstants.JARS_FOR_DESIGNER_X; String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR; for (String file : files) { map.put(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, file), @@ -171,7 +172,7 @@ public class RestoreResultDialog extends JDialog { } private void putJarBackupFilesToInstallEnv(String installHome, Map map, java.util.List list) { - String[] files = UpdateConstants.JARS_FOR_SERVER_X; + 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), diff --git a/designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/UpdateMainDialog.java index 3f99543a37..e4f44086af 100644 --- a/designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/UpdateMainDialog.java @@ -58,12 +58,7 @@ import java.awt.Dimension; import java.awt.Frame; 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.FileReader; -import java.io.FileWriter; -import java.io.IOException; +import java.io.*; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -443,8 +438,8 @@ public class UpdateMainDialog extends UIDialog { return; } if (cacheFile.exists()) { - FileReader reader = new FileReader(cacheFile); - BufferedReader br = new BufferedReader(reader); + InputStreamReader streamReader = new InputStreamReader(new FileInputStream(cacheFile), "UTF-8"); + BufferedReader br = new BufferedReader(streamReader); String readStr, updateTimeStr; while ((readStr = br.readLine()) != null) { @@ -466,7 +461,7 @@ public class UpdateMainDialog extends UIDialog { } } br.close(); - reader.close(); + streamReader.close(); } } @@ -490,8 +485,8 @@ public class UpdateMainDialog extends UIDialog { if (endTime.equals(lastUpdateCacheTime) || jsonArray.length() == 0 || ComparatorUtils.compare(endTime, lastUpdateCacheTime) <= 0) { return; } - FileWriter fileWriter = new FileWriter(cacheFile, true); - BufferedWriter bufferWriter = new BufferedWriter(fileWriter); + OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(cacheFile), "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")); @@ -499,7 +494,7 @@ public class UpdateMainDialog extends UIDialog { bufferWriter.flush(); } bufferWriter.close(); - fileWriter.close(); + writerStream.close(); lastUpdateCacheState = UPDATE_CACHE_STATE_SUCCESS; lastUpdateCacheTime = endTime; cacheProperty.updateProperty("updateTime", lastUpdateCacheTime); @@ -678,7 +673,7 @@ public class UpdateMainDialog extends UIDialog { jarCurrentLabel.setText(downloadFileConfig.optString("buildNO")); } - private void backupFilesFromInstallEnv(String installHome, String todayBackupDir, String[] files) { + private void backupFilesFromInstallEnv(String installHome, String todayBackupDir, List files) { for (String file : files) { try { IOUtils.copy( @@ -690,7 +685,7 @@ public class UpdateMainDialog extends UIDialog { } } - private void backupFilesFromInstallLib(String installHome, String todayBackupDir, String[] files) { + private void backupFilesFromInstallLib(String installHome, String todayBackupDir, List files) { for (String file : files) { try { IOUtils.copy( @@ -734,21 +729,22 @@ public class UpdateMainDialog extends UIDialog { } //获取服务器jar包列表 - private String[] getJARList4Server() { + private List getJARList4Server() { return UpdateConstants.JARS_FOR_SERVER_X; } //获取设计器jar包列表 - private String[] getJARList4Designer() { + private List getJARList4Designer() { return UpdateConstants.JARS_FOR_DESIGNER_X; } //获取服务器jar包下载列表 private String[] getDownLoadJAR4Server() { ArrayList jarList = new ArrayList(); + List serverItems = getJARList4Server(); for (DownloadItem downloadItem : downloadItems) { String downloadItemName = downloadItem.getName(); - if (ArrayUtils.contains(getJARList4Server(), downloadItemName)) { + if (serverItems.contains(downloadItemName)) { jarList.add(downloadItemName); } } @@ -758,9 +754,10 @@ public class UpdateMainDialog extends UIDialog { //获取设计器jar包下载列表 private String[] getDownLoadJAR4Designer() { ArrayList jarList = new ArrayList(); + List designerJarItems = getJARList4Designer(); for (DownloadItem downloadItem : downloadItems) { String downloadItemName = downloadItem.getName(); - if (ArrayUtils.contains(getJARList4Designer(), downloadItemName)) { + if (designerJarItems.contains(downloadItemName)) { jarList.add(downloadItemName); } } @@ -791,7 +788,8 @@ public class UpdateMainDialog extends UIDialog { //判断是否是有效的日志内容 private boolean isValidLogInfo(String logContent) { String log = logContent.toUpperCase(); - for (String s : UpdateConstants.LOG_TYPE) { + List logType = UpdateConstants.LOG_TYPE; + for (String s : logType) { if (log.startsWith(s)) { return true; } From 268f71145e869d85075efff5d639e3125e6bb6bc Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 23 Oct 2018 15:42:40 +0800 Subject: [PATCH 08/11] =?UTF-8?q?REPORT-11993=20=E6=99=AE=E9=80=9A?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=BF=9C=E7=A8=8B=E8=AE=BE=E8=AE=A1=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BF=9E=E6=8E=A5=E6=9D=83=E9=99=90=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/connect/ConnectionComboBoxPanel.java | 10 ++++++++++ designer-base/src/main/java/com/fr/design/mingche.java | 6 ------ 2 files changed, 10 insertions(+), 6 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/mingche.java diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java index 68db344fba..f4a7910b1c 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java @@ -15,11 +15,13 @@ import com.fr.transaction.CallBackAdaptor; import com.fr.transaction.Configurations; import com.fr.transaction.WorkerFacade; import com.fr.workspace.WorkContext; +import com.fr.workspace.server.connection.DBConnectAuth; import javax.swing.SwingUtilities; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -62,8 +64,16 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel { ConnectionConfig mgr = ConnectionConfig.getInstance(); Iterator nameIt = mgr.getConnections().keySet().iterator(); + + Collection noAuthConnections = WorkContext.getCurrent().get(DBConnectAuth.class).getNoAuthConnections(); + if (noAuthConnections == null) { + return nameList.iterator(); + } while (nameIt.hasNext()) { String conName = nameIt.next(); + if (noAuthConnections.contains(conName)) { + continue; + } Connection connection = mgr.getConnection(conName); filterConnection(connection, conName, nameList); } diff --git a/designer-base/src/main/java/com/fr/design/mingche.java b/designer-base/src/main/java/com/fr/design/mingche.java deleted file mode 100644 index da6ffa948c..0000000000 --- a/designer-base/src/main/java/com/fr/design/mingche.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.fr.design; - -public class mingche -{ - -} From 0a81bbe1dbccb3d5dfb03a0162243122a86cb711 Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 24 Oct 2018 17:48:21 +0800 Subject: [PATCH 09/11] =?UTF-8?q?REPORT-11016=2010.0=E7=89=88=E6=9C=ACmac?= =?UTF-8?q?=E4=B8=8A=E7=82=B9=E5=87=BB=E6=9C=80=E5=A4=A7=E5=8C=96=E4=BC=9A?= =?UTF-8?q?=E5=8D=A1=E6=AD=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/com/fr/start/jni/splash.dylib | Bin 32320 -> 41248 bytes 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 designer-realize/src/main/resources/com/fr/start/jni/splash.dylib diff --git a/designer-realize/src/main/resources/com/fr/start/jni/splash.dylib b/designer-realize/src/main/resources/com/fr/start/jni/splash.dylib old mode 100644 new mode 100755 index 3e19cd20e55488220c6ea4559390f4cc112921b9..5d096b2b37d34197e377f7b1ed115c3768bd0d08 GIT binary patch literal 41248 zcmeHP4R}=5nZ5yHgBTLjX;DO@Mi&+GC!--1nS=xfBq0(&x|R-;nHy$cG85+~Kh`{r z8^$snr%ktF>DsOFx7c6o;}5#pMzn&umDFxEYpul=>#(aW#ce@$W%m8PbI#128-CJf z`|R%X^d7kPocEmXd(U^ibMBdY&YaBNqwgR4n5Gp>)->%jTxa6icDkm;wNj)s?HpV_ z6uMlin%1u3to&P5KGY-zr&fpyR2*EcsNNfu0Fjxm_2Z&!<=G-8JS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xU8w=Iz5OVDh&0NdbK%OEfMFd z)|d)ut~8gK=Dh0h<(b7YqU~72BUAn4f1-9}G zU0G^8O(o}%Qz}*d1LkhIIZ@jEPyYmnO%x3N(|#a|kIny!2Y`Ni%@=U{qnK0FZduv- zs2~Dm=Y_3%B{hxr10q z+>h6ItPn&h!JSqcTWEm+dJlAncWM(v0j)W{fs0o1ls`+;R<~OwjQ%XE_>skVR;2k? z&!6wE>eM||dbxE$hvzESf(2Ebm7awi1L68M@?=c}EW}{MJQv$7m&T%JgWgefrEt{^d1Ge1r3H*W-KJCOv%H2G`d0Uw-Y@ zyosGpHtxOuoUVnpynD~j&ii2atv6PE^WKGTHEn5leg5q9+9H45^S8PG`p_rp&wKJ$ z_Re|V`$*T0@5noLsPOfD7alB`@aks=Hh;e54-a32@KRjQrAB`En@>_6n=!eRi$E>{ zxd`MUkc&Vr0=Wp}B9MzfE&{m-{xd`MUkc&Vr0=Wp}B9Mzf aE&{m-{+W!Kk_o_(% From eb1ebc95c833bb8aa30ccee02582a22f4ab62365 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Thu, 25 Oct 2018 10:27:05 +0800 Subject: [PATCH 10/11] =?UTF-8?q?REPORT-11886=20=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E7=9B=AE=E5=BD=95=E6=A0=91=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E5=8D=A1=E9=A1=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/itree/filetree/EnvFileTree.java | 14 +- .../itree/filetree/FileNodeComparator.java | 109 ++++++---- .../design/gui/itree/filetree/JFileTree.java | 201 +++++++++--------- .../gui/itree/filetree/TemplateFileTree.java | 2 +- .../main/java/com/fr/file/FileNodeFILE.java | 8 +- 5 files changed, 177 insertions(+), 157 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java index 0c894ff924..550ba715e5 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java @@ -146,14 +146,14 @@ public class EnvFileTree extends RefreshableJTree { * * 返回currentTreeNode下是否找到了filePath */ - private boolean selectFilePath(ExpandMutableTreeNode currentTreeNode, String prefix, String filePath, DefaultTreeModel m_model) { + private boolean selectFilePath(ExpandMutableTreeNode currentTreeNode, String prefix, String filePath, DefaultTreeModel model) { FileNode fileNode = (FileNode) currentTreeNode.getUserObject(); String nodePath = fileNode.getName(); String currentTreePath = prefix + nodePath; // 如果equals,说明找到了,不必再找下去了 if (ComparatorUtils.equals(new File(currentTreePath), new File(filePath))) { - this.setSelectionPath(new TreePath(m_model.getPathToRoot(currentTreeNode))); + this.setSelectionPath(new TreePath(model.getPathToRoot(currentTreeNode))); return true; } // 如果当前路径是currentFilePath的ParentFile,则expandTreeNode,并继续往下找 @@ -164,7 +164,7 @@ public class EnvFileTree extends RefreshableJTree { for (int i = 0, len = currentTreeNode.getChildCount(); i < len; i++) { ExpandMutableTreeNode childTreeNode = (ExpandMutableTreeNode) currentTreeNode.getChildAt(i); - if (selectFilePath(childTreeNode, prefix, filePath, m_model)) { + if (selectFilePath(childTreeNode, prefix, filePath, model)) { return true; } } @@ -219,7 +219,7 @@ public class EnvFileTree extends RefreshableJTree { resFns = tList.toArray(new FileNode[tList.size()]); } - Arrays.sort(resFns, new FileNodeComparator()); + Arrays.sort(resFns, new FileNodeComparator(FRContext.getFileNodes().getSupportedTypes())); return resFns; } @@ -248,8 +248,8 @@ public class EnvFileTree extends RefreshableJTree { */ public void refreshEnv() { - DefaultTreeModel m_model = (DefaultTreeModel) this.getModel(); - ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) m_model.getRoot(); + DefaultTreeModel model = (DefaultTreeModel) this.getModel(); + ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) model.getRoot(); rootTreeNode.removeAllChildren(); FileNode[] fns; @@ -273,7 +273,7 @@ public class EnvFileTree extends RefreshableJTree { rootTreeNode.add(node); } - m_model.reload(rootTreeNode); + model.reload(rootTreeNode); } /* diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeComparator.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeComparator.java index bf4a5155c7..f963d80d14 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeComparator.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeComparator.java @@ -10,17 +10,45 @@ import java.util.Comparator; * Directory is in the first. and normal file the in the last. */ public class FileNodeComparator implements Comparator { - // 正序还是倒序 - private boolean isReverse = false; - - public FileNodeComparator() { - this(false); - } - - public FileNodeComparator(boolean reverse) { - this.isReverse = reverse; - } - + /** + * 正序还是倒序 + */ + private boolean isReverse; + + /** + * 文件扩展名类型 + */ + private String[] supportTypes; + + /** + * @see FileNodeComparator#FileNodeComparator(boolean, String[]) + * @deprecated + */ + @Deprecated + public FileNodeComparator() { + this(false); + } + + public FileNodeComparator(String[] types) { + this(false, types); + } + + /** + * @param reverse 是否是倒序,{@code true} 倒序,{@code false} 正序 + * @see FileNodeComparator#FileNodeComparator(boolean, String[]) + * @deprecated + */ + @Deprecated + public FileNodeComparator(boolean reverse) { + this.isReverse = reverse; + this.supportTypes = FRContext.getFileNodes().getSupportedTypes(); + } + + public FileNodeComparator(boolean reverse, String[] types) { + this.isReverse = reverse; + this.supportTypes = types; + } + /** * This method should return > 0 if v1 is greater than v2, 0 if * v1 is equal to v2, or < 0 if v1 is less than v2. @@ -29,49 +57,48 @@ public class FileNodeComparator implements Comparator { * @return < 0, 0, or > 0 for v1v2. */ public int compare(FileNode nameNode1, FileNode nameNode2) { - int returnVal; + int returnVal; if (nameNode1.isDirectory()) { if (nameNode2.isDirectory()) { - returnVal = nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase()); + returnVal = nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase()); } else { - returnVal = -1; + returnVal = -1; } } else { if (nameNode2.isDirectory()) { - returnVal = 1; + returnVal = 1; } else { - returnVal=groupByFileType(nameNode1, nameNode2, 0); + returnVal = groupByFileType(nameNode1, nameNode2, 0); } } if (isReverse) { - returnVal = 0 - returnVal; + returnVal = 0 - returnVal; } return returnVal; } /** - * 一个简单的递归判断算法 - * @param nameNode1 - * @param nameNode2 - * @param i - * @return + * 一个简单的递归判断算法,依据文件类型排序 + * + * @param nameNode1 节点1 + * @param nameNode2 节点2 + * @param i i + * @return value */ - private int groupByFileType(FileNode nameNode1, FileNode nameNode2, - int i) { - - String[] supportTypes = FRContext.getFileNodes().getSupportedTypes(); - if (i < supportTypes.length) { - if (nameNode1.isFileType(supportTypes[i])) - if (nameNode2.isFileType(supportTypes[i])) - return nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase()); - else - return-1; - else if (nameNode2.isFileType(supportTypes[i])) - return 1; - else{ - return groupByFileType(nameNode1, nameNode2, i+1); - } - }else - return -1; - } - } \ No newline at end of file + private int groupByFileType(FileNode nameNode1, FileNode nameNode2, + int i) { + if (i < supportTypes.length) { + if (nameNode1.isFileType(supportTypes[i])) + if (nameNode2.isFileType(supportTypes[i])) + return nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase()); + else + return -1; + else if (nameNode2.isFileType(supportTypes[i])) + return 1; + else { + return groupByFileType(nameNode1, nameNode2, i + 1); + } + } else + return -1; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java index 1ade707d49..a1a1567c53 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java @@ -1,5 +1,18 @@ package com.fr.design.gui.itree.filetree; +import com.fr.base.BaseUtils; +import com.fr.design.i18n.Toolkit; +import com.fr.general.ComparatorUtils; +import com.fr.stable.ArrayUtils; +import com.fr.stable.project.ProjectConstants; + +import javax.swing.Icon; +import javax.swing.JTree; +import javax.swing.filechooser.FileSystemView; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreePath; import java.awt.Color; import java.awt.Component; import java.awt.Font; @@ -11,26 +24,12 @@ import java.util.Comparator; import java.util.List; import java.util.Stack; -import javax.swing.Icon; -import javax.swing.JTree; -import javax.swing.filechooser.FileSystemView; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeCellRenderer; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreePath; - -import com.fr.base.BaseUtils; -import com.fr.general.ComparatorUtils; - -import com.fr.stable.ArrayUtils; -import com.fr.stable.project.ProjectConstants; - /** * File Tree. */ public class JFileTree extends AbstractFileTree { - protected FileFilter fileFilter ; + protected FileFilter fileFilter; public JFileTree() { this(null); @@ -43,9 +42,9 @@ public class JFileTree extends AbstractFileTree { private void init(FileFilter filter) { this.fileFilter = filter; - DefaultTreeModel m_model = new DefaultTreeModel(new DefaultMutableTreeNode(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_My_Computer"))); + DefaultTreeModel m_model = new DefaultTreeModel(new DefaultMutableTreeNode(Toolkit.i18nText("Fine-Design_Basic_My_Computer"))); this.setModel(m_model); - + this.putClientProperty("JTree.lineStyle", "Angled"); this.addTreeExpansionListener(this); @@ -57,7 +56,7 @@ public class JFileTree extends AbstractFileTree { } public void setRootFile(File rootFile) { - setRootFiles(new File[] { rootFile }); + setRootFiles(new File[]{rootFile}); } public void setRootFiles(File[] rootFiles) { @@ -65,8 +64,8 @@ public class JFileTree extends AbstractFileTree { return; } - DefaultTreeModel m_model = (DefaultTreeModel) this.getModel(); - DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) m_model.getRoot(); + DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.getModel(); + DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) defaultTreeModel.getRoot(); rootTreeNode.removeAllChildren(); for (int k = 0; k < rootFiles.length; k++) { @@ -78,7 +77,7 @@ public class JFileTree extends AbstractFileTree { } } // richer:不是LocalEnv根本就不会运行到这儿 - m_model.reload(rootTreeNode); + defaultTreeModel.reload(rootTreeNode); if (rootFiles.length == 1) { File expandFile = rootFiles[0]; @@ -96,22 +95,19 @@ public class JFileTree extends AbstractFileTree { public File getSelectedFile() { TreePath selectedTreePath = this.getSelectionPath(); - if(selectedTreePath == null) { + if (selectedTreePath == null) { return null; } DefaultMutableTreeNode currentTreeNode = this.getMutableTreeNode(selectedTreePath); - StringBuffer fBuf = new StringBuffer(); - while (true) { - // 如果已经到了根节点,直接退出. - if (currentTreeNode == null) { - break; - } + StringBuilder fBuf = new StringBuilder(); + while (currentTreeNode != null) { + // 如果已经到了根节点,直接退出. Object object = currentTreeNode.getUserObject(); if (object instanceof RootFile) { - // 当前文件. - RootFile rootFileNode = (RootFile) object; + // 当前文件. + RootFile rootFileNode = (RootFile) object; return new File(rootFileNode.getFile() + fBuf.toString()); } @@ -128,6 +124,7 @@ public class JFileTree extends AbstractFileTree { /** * 通过文件夹寻找展开路径 + * * @param currentFile 当前文件 */ public void selectFile(File currentFile) { @@ -181,26 +178,25 @@ public class JFileTree extends AbstractFileTree { /** * 列出当前所有的File + * * @param currentTreeNode 当前文件节点 * @return 当前节点下的所有File */ + @Override public FileDirectoryNode[] listFileNodes(DefaultMutableTreeNode currentTreeNode) { - StringBuffer fBuf = new StringBuffer(); - while (true) { - // 如果已经到了根节点,直接退出. - if (currentTreeNode == null) { - break; - } + StringBuilder fBuf = new StringBuilder(); + while (currentTreeNode != null) { + // 如果已经到了根节点,直接退出. Object object = currentTreeNode.getUserObject(); if (object instanceof RootFile) { - RootFile rootFileNode = (RootFile) object; + RootFile rootFileNode = (RootFile) object; // 当前文件. (rootFileNode + fBuf.toString = Path  local地址) File currentFile = new File(rootFileNode.getFile() + fBuf.toString()); // 列出当前文件的所有子文件,要判断下是否是系统保护的文件 能否打开. 打不开的话显示为null File[] files = currentFile.listFiles(); // 如果文件列表为null 或者为File[0] = []返回null - if (files == null ) { - return new FileDirectoryNode[0]; + if (files == null) { + return new FileDirectoryNode[0]; } List fileNodeList = new ArrayList(); for (int k = 0; k < files.length; k++) { @@ -211,8 +207,8 @@ public class JFileTree extends AbstractFileTree { } // 过滤只显示文件夹 并进行 名字简化 if (fileFilter.accept(tmpFile)) { - // newNode 传递 isDirectory属性 并且只显示文件夹名字 - FileDirectoryNode newNode = FileDirectoryNode.createFileDirectoryNode(tmpFile); + // newNode 传递 isDirectory属性 并且只显示文件夹名字 + FileDirectoryNode newNode = FileDirectoryNode.createFileDirectoryNode(tmpFile); fileNodeList.add(newNode); } } @@ -220,78 +216,77 @@ public class JFileTree extends AbstractFileTree { FileDirectoryNode[] fileNodes = new FileDirectoryNode[fileNodeList.size()]; fileNodeList.toArray(fileNodes); // 对文件夹进行排序 - Arrays.sort(fileNodes, new FileNodeComparator()); + Arrays.sort(fileNodes, new FileDirectoryNodeComparator()); return fileNodes; } // 名字进行逐层反序的回加. 例: Doload ==> C:\java\Doload ,返回到文件夹的path,因为有可能是String. 所以加上instanceof if (object instanceof FileDirectoryNode) { - FileDirectoryNode nameNode = (FileDirectoryNode)object; - fBuf.insert(0, nameNode.getName()); - fBuf.insert(0, "/"); + FileDirectoryNode nameNode = (FileDirectoryNode) object; + fBuf.insert(0, nameNode.getName()); + fBuf.insert(0, "/"); } // 逐层返回 currentTreeNode = (DefaultMutableTreeNode) currentTreeNode.getParent(); } return new FileDirectoryNode[0]; } - + /** - * cellRenderer: tree中显示文件的类型图标 + * cellRenderer: tree中显示文件的类型图标 */ - private DefaultTreeCellRenderer fileTreeCellRenderer = new DefaultTreeCellRenderer() { - - public Component getTreeCellRendererComponent(JTree tree, Object value, - boolean selected, boolean expanded, boolean leaf, int row, - boolean hasFocus) { - super.getTreeCellRendererComponent(tree, value, selected, expanded, - leaf, row, hasFocus); - - DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value; - StringBuffer fBuf = new StringBuffer(); - while(true) { - if (treeNode == null) { - break; - } - Object userObj = treeNode.getUserObject(); - if (userObj instanceof RootFile) { - RootFile rootFileNode = (RootFile) userObj; - // 当前文件的全部路径. (rootFileNode + fBuf.toString = Path  local地址) - File currentFile = new File(rootFileNode.getFile() + fBuf.toString()); - FileSystemView view = FileSystemView.getFileSystemView(); - // File的全部路径. - // 得到本地tree图标 - Icon tmpIcon = view.getSystemIcon(currentFile); + private DefaultTreeCellRenderer fileTreeCellRenderer = new DefaultTreeCellRenderer() { + + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, + boolean selected, boolean expanded, boolean leaf, int row, + boolean hasFocus) { + super.getTreeCellRendererComponent(tree, value, selected, expanded, + leaf, row, hasFocus); + + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value; + StringBuilder fBuf = new StringBuilder(); + while (treeNode != null) { + Object userObj = treeNode.getUserObject(); + if (userObj instanceof RootFile) { + RootFile rootFileNode = (RootFile) userObj; + // 当前文件的全部路径. (rootFileNode + fBuf.toString = Path  local地址) + File currentFile = new File(rootFileNode.getFile() + fBuf.toString()); + FileSystemView view = FileSystemView.getFileSystemView(); + // File的全部路径. + // 得到本地tree图标 + Icon tmpIcon = view.getSystemIcon(currentFile); if (currentFile.isDirectory() && fBuf.length() > 0) { - tmpIcon=BaseUtils.readIcon("/com/fr/design/images/gui/folder.png"); + tmpIcon = BaseUtils.readIcon("/com/fr/design/images/gui/folder.png"); } this.setIcon(tmpIcon); - this.setName(null); - Font oldFont = this.getFont(); - if(ComparatorUtils.equals(currentFile.getName(), ProjectConstants.WEBINF_NAME)){ - this.setForeground(Color.blue); - this.setFont(new Font(oldFont.getName(),1,oldFont.getSize())); - }else{ - this.setFont(new Font(oldFont.getName(),0,oldFont.getSize())); - } - } - // 名字进行逐层反序的回加. 例: Doload ==> C:\java\Doload - if (userObj instanceof FileDirectoryNode ) { - FileDirectoryNode nameNode = (FileDirectoryNode)userObj; - fBuf.insert(0, nameNode.getName()); - fBuf.insert(0, "/"); - } - // 逐层往上 倒退返回 - treeNode = (DefaultMutableTreeNode) treeNode.getParent(); - } - return this; - } - }; - + this.setName(null); + Font oldFont = this.getFont(); + if (ComparatorUtils.equals(currentFile.getName(), ProjectConstants.WEBINF_NAME)) { + this.setForeground(Color.blue); + this.setFont(new Font(oldFont.getName(), Font.BOLD, oldFont.getSize())); + } else { + this.setFont(new Font(oldFont.getName(), Font.PLAIN, oldFont.getSize())); + } + } + // 名字进行逐层反序的回加. 例: Doload ==> C:\java\Doload + if (userObj instanceof FileDirectoryNode) { + FileDirectoryNode nameNode = (FileDirectoryNode) userObj; + fBuf.insert(0, nameNode.getName()); + fBuf.insert(0, "/"); + } + // 逐层往上 倒退返回 + treeNode = (DefaultMutableTreeNode) treeNode.getParent(); + } + return this; + } + }; + /** - * 对文件夹进行排序 先文件夹 然后各种类型文件 + * 对文件夹进行排序 先文件夹 然后各种类型文件 + * * @author kunsnat */ - public class FileNodeComparator implements Comparator { + public class FileDirectoryNodeComparator implements Comparator { /** * This method should return > 0 if v1 is greater than v2, 0 if * v1 is equal to v2, or < 0 if v1 is less than v2. @@ -302,21 +297,19 @@ public class JFileTree extends AbstractFileTree { * @param v2 comparison value.值2 * @return < 0, 0, or > 0 for v1v2 .值1大于值2返回大于0,相等返回0,小于和大于相反 */ - public int compare(Object v1, Object v2) { - FileDirectoryNode nameNode1 = (FileDirectoryNode) v1; - FileDirectoryNode nameNode2 = (FileDirectoryNode) v2; - - if (nameNode1.isDirectory()) { - if (nameNode2.isDirectory()) { - return nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase()); + @Override + public int compare(FileDirectoryNode v1, FileDirectoryNode v2) { + if (v1.isDirectory()) { + if (v2.isDirectory()) { + return v1.getName().toLowerCase().compareTo(v2.getName().toLowerCase()); } else { return -1; } } else { - if (nameNode2.isDirectory()) { + if (v2.isDirectory()) { return 1; } else { - return nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase()); + return v1.getName().toLowerCase().compareTo(v2.getName().toLowerCase()); } } } diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java index 0a13dd1bdb..f9b18b7f8d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java @@ -217,7 +217,7 @@ public class TemplateFileTree extends EnvFileTree { fileNodes = list.toArray(new FileNode[list.size()]); } - Arrays.sort(fileNodes, new FileNodeComparator()); + Arrays.sort(fileNodes, new FileNodeComparator(FRContext.getFileNodes().getSupportedTypes())); return fileNodes; } 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 84724df35e..207c51d24a 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java @@ -211,7 +211,7 @@ public class FileNodeFILE implements FILE { try { FileNode[] nodeArray; nodeArray = listFile(node.getEnvPath()); - Arrays.sort(nodeArray, new FileNodeComparator()); + Arrays.sort(nodeArray, new FileNodeComparator(FRContext.getFileNodes().getSupportedTypes())); return fileNodeArray2FILEArray(nodeArray, envPath); } catch (Exception e) { @@ -240,7 +240,7 @@ public class FileNodeFILE implements FILE { return FRContext.getFileNodes().list(rootFilePath); } } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } return new FileNode[0]; } @@ -280,7 +280,7 @@ public class FileNodeFILE implements FILE { try { return FRContext.getCommonOperator().fileLocked(node.getEnvPath()); } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; } } @@ -304,7 +304,7 @@ public class FileNodeFILE implements FILE { try { return WorkContext.getWorkResource().exist(node.getEnvPath()); } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; } } From db2334e1965acb05a8e5641d14fef5406fb02e24 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Thu, 25 Oct 2018 10:29:01 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/gui/itree/filetree/JFileTree.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java index a1a1567c53..69875a97fb 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java @@ -42,8 +42,8 @@ public class JFileTree extends AbstractFileTree { private void init(FileFilter filter) { this.fileFilter = filter; - DefaultTreeModel m_model = new DefaultTreeModel(new DefaultMutableTreeNode(Toolkit.i18nText("Fine-Design_Basic_My_Computer"))); - this.setModel(m_model); + DefaultTreeModel treeModel = new DefaultTreeModel(new DefaultMutableTreeNode(Toolkit.i18nText("Fine-Design_Basic_My_Computer"))); + this.setModel(treeModel); this.putClientProperty("JTree.lineStyle", "Angled");