diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 7242b2295..9c23dcc51 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -390,9 +390,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } File envHome = new File(userHome + File.separator + "." + ProductConstants.APP_NAME + version); - if (!envHome.exists()) { - StableUtils.mkdirs(envHome); - } return envHome.getAbsolutePath(); } diff --git a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java index cf4f02f40..f1094d331 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java @@ -1,5 +1,6 @@ package com.fr.design.actions.help; +import com.fr.design.i18n.Toolkit; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; import com.fr.general.CloudCenter; @@ -27,7 +28,11 @@ public class TutorialAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind(createDocKey()); + return CloudCenter.getInstance().acquireUrlByKind(createDocKey(), "http://help.finereport.com"); + } + + public String getOffLineWarnMessage() { + return Toolkit.i18nText("Fine-Design_Offline_Helptutorial_Msg"); } // 生成帮助文档 sitecenter key, help.zh_CN.10 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 b5bc39e4e..f65610526 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 @@ -25,6 +25,7 @@ import com.fr.design.gui.icombobox.UIComboBoxEditor; import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -39,7 +40,16 @@ import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.server.connection.DBConnectAuth; -import javax.swing.*; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.util.Collections; +import java.util.concurrent.CancellationException; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTree; +import javax.swing.SwingWorker; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.PopupMenuEvent; @@ -50,7 +60,6 @@ import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; -import java.awt.*; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; @@ -70,6 +79,9 @@ import java.util.concurrent.FutureTask; * @since 2012-7-11下午4:49:39 */ public class ChoosePane extends BasicBeanPane implements Refreshable, Previewable, Prepare4DataSourceChange { + + private static final List PENDING_CONTENT = new ArrayList<>(Collections.singletonList(Toolkit.i18nText("Fine-Design_Basic_Loading") + "...")); + private static final double COLUMN_SIZE = 24; /** @@ -91,6 +103,8 @@ public class ChoosePane extends BasicBeanPane implements Refresha private SwingWorker populateWorker; + private SwingWorker, Void> initWorker; + private PopupMenuListener popupMenuListener = new PopupMenuListener() { @Override @@ -213,10 +227,34 @@ public class ChoosePane extends BasicBeanPane implements Refresha @SuppressWarnings("unchecked") protected void initDsNameComboBox() { + if (initWorker != null && !initWorker.isDone()) { + initWorker.cancel(true); + } dsNameComboBox.setRefreshingModel(true); - FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(getHasAuthConnections()); - dsNameComboBox.setModel(dsNameComboBoxModel); - dsNameComboBox.setRefreshingModel(false); + dsNameComboBox.setModel(new FilterableComboBoxModel(PENDING_CONTENT)); + initWorker = new SwingWorker, Void>() { + + @Override + protected List doInBackground() throws Exception { + return getHasAuthConnections(); + } + + @Override + protected void done() { + try { + FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(get()); + String selected = dsNameComboBox.getSelectedItem(); + dsNameComboBox.setModel(dsNameComboBoxModel); + dsNameComboBox.setSelectedItem(selected); + dsNameComboBox.setRefreshingModel(false); + } catch (Exception e) { + if (!(e instanceof CancellationException)) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } + }; + initWorker.execute(); } protected void initComponentsLayout(PreviewLabel previewLabel, int labelSize) { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java index f06d1405b..248d3318c 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java @@ -3,12 +3,19 @@ package com.fr.design.data.datapane.connect; import com.fr.base.BaseUtils; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import javax.swing.*; -import java.awt.*; +import com.fr.log.FineLoggerFactory; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.util.Iterator; +import java.util.concurrent.CancellationException; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JPanel; +import javax.swing.SwingWorker; public abstract class ItemEditableComboBoxPanel extends JPanel { /** @@ -16,6 +23,8 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { */ private static final long serialVersionUID = 1L; + private static final String PENDING = Toolkit.i18nText("Fine-Design_Basic_Loading") + "..."; + protected static final Object EMPTY = new Object() { public String toString() { return ""; @@ -26,6 +35,8 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { protected UIButton editButton; protected UIButton refreshButton; + private SwingWorker, Void> refreshWorker; + public ItemEditableComboBoxPanel() { super(); @@ -75,26 +86,42 @@ public abstract class ItemEditableComboBoxPanel extends JPanel { * 刷新itemComboBox的内容 */ protected void refreshItems() { - // 记录原来选中的Item,重新加载后需要再次选中 - Object lastSelectedItem = itemComboBox.getSelectedItem(); + + if (refreshWorker != null && !refreshWorker.isDone()) { + refreshWorker.cancel(true); + } DefaultComboBoxModel model = ((DefaultComboBoxModel) itemComboBox.getModel()); model.removeAllElements(); // 先加EMPTY,再加items model.addElement(EMPTY); + model.addElement(PENDING); - java.util.Iterator itemIt = items(); - while(itemIt.hasNext()) { - model.addElement(itemIt.next()); - } + refreshWorker = new SwingWorker, Void>() { + @Override + protected Iterator doInBackground() throws Exception { + return items(); + } - // 再次选中之前选中的Item - int idx = model.getIndexOf(lastSelectedItem); - if(idx < 0) { - idx = 0; - } - itemComboBox.setSelectedIndex(idx); + @Override + protected void done() { + try { + Iterator itemIt = get(); + model.removeElement(PENDING); + while(itemIt.hasNext()) { + model.addElement(itemIt.next()); + } + itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() + 1); + } catch (Exception e) { + if (!(e instanceof CancellationException)) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + } + }; + refreshWorker.execute(); } /* diff --git a/designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java b/designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java index 2662198bb..f38fc1d08 100644 --- a/designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java +++ b/designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java @@ -6,6 +6,9 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.login.utils.DesignerLoginUtils; import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.utils.BrowseUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; + import java.awt.event.ActionEvent; import java.util.HashMap; import java.util.Map; @@ -21,6 +24,10 @@ public abstract class AbstractDesignerSSO extends UpdateAction { public void actionPerformed(ActionEvent event) { String url = getJumpUrl(); if (!DesignerLoginUtils.isOnline()) { + String message = getOffLineWarnMessage(); + if (StringUtils.isNotEmpty(message)) { + FineLoggerFactory.getLogger().warn(message); + } BrowseUtils.browser(url); return; } @@ -47,4 +54,8 @@ public abstract class AbstractDesignerSSO extends UpdateAction { } public abstract String getJumpUrl(); + + public String getOffLineWarnMessage() { + return StringUtils.EMPTY; + } } diff --git a/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java b/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java index 349503bd7..810a71e85 100644 --- a/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java +++ b/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java @@ -152,13 +152,11 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { private ScrollAction PRESS_ACTION = new ScrollAction() { @Override public boolean run(MouseEvent evt, int index, double tmpSize1, double tmpSize2, int tmpIncreaseSize, int oldEndValueSize, ElementCase report, DynamicUnitList sizeList) { -// int resolution = ScreenResolution.getScreenResolution(); - if (isOnSeparatorLineIncludeZero(evt, tmpSize2, tmpIncreaseSize) || isOnNormalSeparatorLine(evt, tmpSize2)) { dragType = GridUtils.DRAG_CELL_SIZE; isDragPermited = true; dragIndex = index; - showToolTip(evt, createToolTipString(sizeList.get(dragIndex).toPixD(resolution), sizeList.getRangeValue(0, dragIndex + 1).toPixD(resolution))); + showToolTip(evt, createToolTipString(sizeList.get(dragIndex), sizeList.getRangeValue(0, dragIndex + 1))); return true; } if (between(evt, tmpSize1, tmpSize2)) { @@ -302,21 +300,18 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { protected abstract void resetGridSelectionBySelect(int index, ElementCasePane ePane); - private String createToolTipString(double doubleValue, double totalDoubleValue) { + private String createToolTipString(UNIT unitValue, UNIT totalUnitValue) { int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit(); -// int resolution = ScreenResolution.getScreenResolution(); - FU ulen = FU.valueOfPix((int) doubleValue, resolution); - FU tulen = FU.valueOfPix((int) totalDoubleValue, resolution); ReportLengthUNITProvider lengthUNIT = UnitConvertUtil.parseLengthUNIT(unitType); String unit = lengthUNIT.unitText(); - double len = lengthUNIT.unit2Value4Scale(ulen); - double tlen = lengthUNIT.unit2Value4Scale(tulen); + double len = lengthUNIT.unit2Value4Scale(unitValue); + double tlen = lengthUNIT.unit2Value4Scale(totalUnitValue); StringBuilder sb = new StringBuilder(); sb.append(String.format("%.2f", new Double(len))) .append('/').append(String.format("%.2f", new Double(tlen))) .append(unit).append('(') - .append((int)(doubleValue)).append('/') - .append((int)(totalDoubleValue)) + .append((int)(unitValue.toPixD(resolution))).append('/') + .append((int)(totalUnitValue.toPixD(resolution))) .append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Px")) .append(')'); return sb.toString(); @@ -416,8 +411,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { iterateScrollBar(ePane, evt, DRAG_ACTION); DynamicUnitList sizeList = getSizeList(report); -// int resolution = ScreenResolution.getScreenResolution(); - this.setToolTipText2(this.createToolTipString(sizeList.get(dragIndex).toPixD(resolution), sizeList.getRangeValue(0, dragIndex + 1).toPixD(resolution))); + this.setToolTipText2(this.createToolTipString(sizeList.get(dragIndex), sizeList.getRangeValue(0, dragIndex + 1))); } ePane.repaint(); 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 07044b82c..ba51d6d64 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUI.java @@ -10,12 +10,15 @@ import com.fr.base.background.ColorBackground; import com.fr.base.background.ImageFileBackground; import com.fr.base.iofile.attr.WatermarkAttr; import com.fr.base.vcs.DesignerMode; +import com.fr.design.DesignerEnvManager; import com.fr.design.constants.UIConstants; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.fun.ReportLengthUNITProvider; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.JTemplate; import com.fr.design.roleAuthority.ReportAndFSManagePane; +import com.fr.design.unit.UnitConvertUtil; import com.fr.general.Background; import com.fr.general.ComparatorUtils; import com.fr.grid.selection.CellSelection; @@ -48,6 +51,7 @@ import com.fr.stable.Constants; import com.fr.stable.script.CalculatorUtils; import com.fr.stable.unit.FU; import com.fr.stable.AssistUtils; +import com.fr.stable.unit.UNIT; import com.fr.third.antlr.ANTLRException; import com.fr.third.guava.collect.HashMultimap; @@ -365,10 +369,10 @@ public class GridUI extends ComponentUI { private class DrawVerticalLineHelper extends DrawLineHelper { - DrawVerticalLineHelper(GridRange gridRange, boolean showGridLine, boolean discardExtraGridLine, + DrawVerticalLineHelper(GridRange gridRange, boolean showGridLine, boolean showExtraGridLine, boolean showPaginateLine, double paperPaintSize, List paginateLineList, int resolution) { - super(gridRange, showGridLine, discardExtraGridLine, showPaginateLine, + super(gridRange, showGridLine, showExtraGridLine, showPaginateLine, paperPaintSize, paginateLineList, resolution); } @@ -384,47 +388,47 @@ public class GridUI extends ComponentUI { @Override protected void iterateStart2End(Graphics2D g2d) { - float rowHeight, paperYAxisSumSize = 0, maxXAxisSumSize = 0, yAxisSumSize = 0; + UNIT rowHeight, paperYAxisSumSize = FU.getInstance(0), maxXAxisSumSize = FU.getInstance(0), yAxisSumSize = FU.getInstance(0); for (int i = 0; i <= gridRange.yEndIndex; i++) { if (i == 0) { i = gridRange.yBeginIndex; for (int k = 0; k < gridRange.yBeginIndex; k++) { - rowHeight = gridRange.rowHeightList.get(k).toPixF(resolution); - - paperYAxisSumSize += rowHeight; - if (paperYAxisSumSize >= paperPaintSize) { + rowHeight = gridRange.rowHeightList.get(k); + paperYAxisSumSize = paperYAxisSumSize.add(rowHeight); + if (paperYAxisSumSize.toPixF(resolution) >= paperPaintSize) { paperYAxisSumSize = rowHeight; } } } - rowHeight = gridRange.rowHeightList.get(i).toPixF(resolution); - paperYAxisSumSize += rowHeight; + + rowHeight = gridRange.rowHeightList.get(i); + paperYAxisSumSize = paperYAxisSumSize.add(rowHeight); if (showGridLine) { - float columnWidth, xAxisSumSize = 0; + UNIT columnWidth, xAxisSumSize = FU.getInstance(0); for (int j = gridRange.xBeginIndex; j <= gridRange.xEndIndex; j++) { - columnWidth = gridRange.columnWidthList.get(j).toPixF(resolution); + columnWidth = gridRange.columnWidthList.get(j); if (!mergeCellElementTable.get(CellPosition.value(i - 1, j)).contains(CellPosition.BOTTOM)) { - tmpLine2D.setLine(xAxisSumSize, yAxisSumSize, xAxisSumSize + columnWidth, yAxisSumSize); + tmpLine2D.setLine(xAxisSumSize.toPixF(resolution), yAxisSumSize.toPixF(resolution), xAxisSumSize.add(columnWidth).toPixF(resolution), yAxisSumSize.toPixF(resolution)); g2d.draw(tmpLine2D); } - xAxisSumSize += columnWidth; + xAxisSumSize = xAxisSumSize.add(columnWidth); } - if (xAxisSumSize > maxXAxisSumSize) { + if (xAxisSumSize.toPixF(resolution) > maxXAxisSumSize.toPixF(resolution)) { maxXAxisSumSize = xAxisSumSize; } } - if (showPaginateLine && paperYAxisSumSize - paperPaintSize > THRESHOLD) { - paginateLineList.add(getPaginateLine2D((int) yAxisSumSize)); + if (showPaginateLine && paperYAxisSumSize.toPixF(resolution) - paperPaintSize > THRESHOLD) { + paginateLineList.add(getPaginateLine2D((int) yAxisSumSize.toPixF(resolution))); paperYAxisSumSize = rowHeight; } - yAxisSumSize += rowHeight; + yAxisSumSize = yAxisSumSize.add(rowHeight); } // paint 最后一个横线.. if (showGridLine) { if (showExtraGridLine) { - drawLastLine(g2d, (int) yAxisSumSize); + drawLastLine(g2d, (int) yAxisSumSize.toPixF(resolution)); } else { - GraphHelper.drawLine(g2d, 0, yAxisSumSize, maxXAxisSumSize, yAxisSumSize); + GraphHelper.drawLine(g2d, 0, yAxisSumSize.toPixF(resolution), maxXAxisSumSize.toPixF(resolution), yAxisSumSize.toPixF(resolution)); } } } @@ -432,10 +436,10 @@ public class GridUI extends ComponentUI { private class DrawHorizontalLineHelper extends DrawLineHelper { - DrawHorizontalLineHelper(GridRange gridRange, boolean showGridLine, boolean discardExtraGridLine, + DrawHorizontalLineHelper(GridRange gridRange, boolean showGridLine, boolean showExtraGridLine, boolean showPaginateLine, double paperPaintSize, List paginateLineList, int resolution) { - super(gridRange, showGridLine, discardExtraGridLine, showPaginateLine, + super(gridRange, showGridLine, showExtraGridLine, showPaginateLine, paperPaintSize, paginateLineList, resolution); } @@ -451,46 +455,46 @@ public class GridUI extends ComponentUI { @Override protected void iterateStart2End(Graphics2D g2d) { - float columnWidth, paperXAxisSumSize = 0, maxYAxisSumSize = 0, xAxisSumSize = 0; + UNIT columnWidth, paperXAxisSumSize = FU.getInstance(0), maxYAxisSumSize = FU.getInstance(0), xAxisSumSize = FU.getInstance(0); for (int i = 0; i <= gridRange.xEndIndex; i++) { if (i == 0) { i = gridRange.xBeginIndex; for (int k = 0; k < gridRange.xBeginIndex; k++) { - columnWidth = gridRange.columnWidthList.get(k).toPixF(resolution); - paperXAxisSumSize += columnWidth; - if (paperXAxisSumSize >= paperPaintSize) { + columnWidth = gridRange.columnWidthList.get(k); + paperXAxisSumSize = paperXAxisSumSize.add(columnWidth); + if (paperXAxisSumSize.toPixF(resolution) >= paperPaintSize) { paperXAxisSumSize = columnWidth; } } } - columnWidth = gridRange.columnWidthList.get(i).toPixF(resolution); - paperXAxisSumSize += columnWidth; + columnWidth = gridRange.columnWidthList.get(i); + paperXAxisSumSize = paperXAxisSumSize.add(columnWidth); if (showGridLine) { - float rowHeight, yAxisSumSize = 0; + UNIT rowHeight, yAxisSumSize = FU.getInstance(0); for (int j = gridRange.yBeginIndex; j <= gridRange.yEndIndex; j++) { - rowHeight = gridRange.rowHeightList.get(j).toPixF(resolution); + rowHeight = gridRange.rowHeightList.get(j); if (!mergeCellElementTable.get(CellPosition.value(j, i - 1)).contains(CellPosition.RIGHT)) { - tmpLine2D.setLine(xAxisSumSize, yAxisSumSize, xAxisSumSize, yAxisSumSize + rowHeight); + tmpLine2D.setLine(xAxisSumSize.toPixF(resolution), yAxisSumSize.toPixF(resolution), xAxisSumSize.toPixF(resolution), yAxisSumSize.add(rowHeight).toPixF(resolution)); g2d.draw(tmpLine2D); } - yAxisSumSize += rowHeight; + yAxisSumSize = yAxisSumSize.add(rowHeight); } - if (yAxisSumSize > maxYAxisSumSize) { + if (yAxisSumSize.toPixF(resolution) > maxYAxisSumSize.toPixF(resolution)) { maxYAxisSumSize = yAxisSumSize; } } - if (showPaginateLine && paperXAxisSumSize - paperPaintSize > THRESHOLD) { - paginateLineList.add(getPaginateLine2D((int) xAxisSumSize)); + if (showPaginateLine && paperXAxisSumSize.toPixF(resolution) - paperPaintSize > THRESHOLD) { + paginateLineList.add(getPaginateLine2D((int) xAxisSumSize.toPixF(resolution))); paperXAxisSumSize = columnWidth; } - xAxisSumSize += columnWidth; + xAxisSumSize = xAxisSumSize.add(columnWidth); } // paint 最后一个横线.. if (showGridLine) { if (showExtraGridLine) { - drawLastLine(g2d, (int) xAxisSumSize); + drawLastLine(g2d, (int) xAxisSumSize.toPixD(resolution)); } else { - GraphHelper.drawLine(g2d, xAxisSumSize, 0, xAxisSumSize, maxYAxisSumSize); + GraphHelper.drawLine(g2d, xAxisSumSize.toPixF(resolution), 0, xAxisSumSize.toPixF(resolution), maxYAxisSumSize.toPixF(resolution)); } } }