Browse Source

Pull request #5360: REPORT-56595 数据集预览时可复制-表头复制问题 && REPORT-55481 模板Web属性的顶部和底部工具栏在权限编辑时,顶部工具栏被底部工具栏覆盖

Merge in DESIGN/design from ~HENRY.WANG/design:feature/10.0 to feature/10.0

* commit 'bee3075e5f291f3436ad1d4e74ade0648b0dfa42':
  REPORT-55481 模板Web属性的顶部和底部工具栏在权限编辑时,顶部工具栏被底部工具栏覆盖
  REPORT-56595 数据集预览时可复制-表头复制问题
feature/10.0
Henry.Wang 3 years ago
parent
commit
db9751cd0a
  1. 116
      designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java
  2. 10
      designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java

116
designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java

@ -6,7 +6,11 @@ import com.fr.design.gui.itable.TableSorter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.os.OperatingSystem;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
@ -40,27 +44,104 @@ public class CopyableJTable extends SortableJTable {
int commandKeyCode = 157;
//选中单元格的背景色
Color selectBackGround = new Color(54, 133, 242, 63);
Color headerBackGround = new Color(229, 229, 229);
boolean mouseDrag = false;
boolean headerSelect = false;
DefaultTableCellRenderer tableHeaderCellRenderer = new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (isChoose(row, column)) {
comp.setBackground(selectBackGround);
} else {
comp.setBackground(headerBackGround);
}
return comp;
}
};
public CopyableJTable(TableSorter tableModel) {
super(tableModel);
initListener();
this.getTableHeader().setDefaultRenderer(tableHeaderCellRenderer);
}
private void initListener() {
CopyableJTable self = this;
this.getTableHeader().addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
if (mouseDrag) {
headerSelect = true;
int column = getColumn(e);
self.updateEndPoint(-1, column);
self.getTableHeader().repaint();
}
}
@Override
public void mouseExited(MouseEvent e) {
if (mouseDrag) {
headerSelect = false;
}
}
@Override
public void mouseClicked(MouseEvent e) {
headerSelect = true;
int column = getColumn(e);
if (column != -1) {
self.clearPoint();
self.addPoint(-1, column);
self.updateStartPoint(-1, column);
self.updateEndPoint(-1, column);
self.refreshTable();
}
}
private int getColumn(MouseEvent e) {
JTableHeader h = (JTableHeader) e.getSource();
TableColumnModel columnModel = h.getColumnModel();
int viewColumn = columnModel.getColumnIndexAtX(e.getX());
return viewColumn;
}
});
this.getTableHeader().addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
mouseDrag = false;
}
@Override
public void mouseDragged(MouseEvent e) {
self.clearPoint();
self.updateStartPoint(-1, -1);
self.updateEndPoint(-1, -1);
self.refreshTable();
}
});
this.addMouseMotionListener(new java.awt.event.MouseAdapter() {
@Override
public void mouseDragged(MouseEvent evt) {
mouseDrag = true;
int row = self.rowAtPoint(evt.getPoint());
int col = self.columnAtPoint(evt.getPoint());
if (self.updateEndPoint(row, col)) {
self.repaint();
self.refreshTable();
}
}
public void mouseMoved(MouseEvent e) {
mouseDrag = false;
}
});
this.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
headerSelect = false;
int row = self.rowAtPoint(e.getPoint());
int col = self.columnAtPoint(e.getPoint());
if (!self.isControlDown) {
@ -74,7 +155,7 @@ public class CopyableJTable extends SortableJTable {
self.addPoint(row, col);
self.updateEndPoint(row, col);
self.repaint();
self.refreshTable();
}
});
@ -129,6 +210,8 @@ public class CopyableJTable extends SortableJTable {
private boolean updateEndPoint(int row, int col) {
if (headerSelect && row != -1)
return false;
if (endRow != row || endCol != col) {
endRow = row;
endCol = col;
@ -157,13 +240,12 @@ public class CopyableJTable extends SortableJTable {
private void copy() {
FineLoggerFactory.getLogger().info("copy cell value");
java.util.List<java.util.List<Object>> table = new ArrayList<>();
if ((startRow != endRow || startCol != endCol) &&
Math.min(startRow, endRow) > -1 && Math.min(startCol, endCol) > -1) {
if ((startRow != endRow || startCol != endCol) && Math.min(startCol, endCol) > -1) {
for (int i = Math.min(startRow, endRow); i <= Math.max(startRow, endRow); i++) {
table.add(new ArrayList<>());
for (int j = Math.min(startCol, endCol); j <= Math.max(startCol, endCol); j++) {
Object text = this.getValueAt(i, j);
table.get(i - Math.min(startRow, endRow)).add(text);
Object text = this.getTableValue(i, j);
table.get(table.size() - 1).add(text);
}
}
} else if (pointList.size() > 0) {
@ -176,8 +258,8 @@ public class CopyableJTable extends SortableJTable {
table.add(new ArrayList<>());
currentRow++;
}
Object text = this.getValueAt(point.x, point.y);
table.get(currentRow - startRow).add(text);
Object text = this.getTableValue(point.x, point.y);
table.get(table.size() - 1).add(text);
}
}
@ -186,6 +268,24 @@ public class CopyableJTable extends SortableJTable {
clip.setContents(tText, null);
}
private Object getTableValue(int row, int col) {
Object value = null;
if (col > -1) {
if (row > -1) {
value = this.getValueAt(row, col);
} else if (row == -1) {
col = columnModel.getColumn(col).getModelIndex();
value = this.getModel().getColumnName(col);
}
}
return value;
}
private void refreshTable() {
this.repaint();
this.getTableHeader().repaint();
}
private boolean isChoose(int row, int col) {
if (row >= Math.min(startRow, endRow) && row <= Math.max(startRow, endRow)) {
if (col >= Math.min(startCol, endCol) && col <= Math.max(startCol, endCol)) {

10
designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java

@ -185,7 +185,7 @@ public class AuthorityToolBarPane<T extends WebContent> extends BasicBeanPane<Re
*/
private void checkToolBarPaneEnable() {
List<ToolBarButton> toolBarButtons = toolBarPane.getToolBarButtons();
boolean isnotEnable = ComparatorUtils.equals(title.getText(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Server_Toolbar_Choose_Role"))&& !WorkContext.getCurrent().isRoot();
boolean isnotEnable = ComparatorUtils.equals(title.getText(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Server_Toolbar_Choose_Role")) && !WorkContext.getCurrent().isRoot();
for (ToolBarButton button : toolBarButtons) {
button.setEnabled(!isnotEnable);
}
@ -296,9 +296,15 @@ public class AuthorityToolBarPane<T extends WebContent> extends BasicBeanPane<Re
if (toolBarManager.length == 0) {
return;
}
ToolBar resultToolbar = new ToolBar();
for (int i = 0; i < toolBarManager.length; i++) {
toolBarPane.populateBean(toolBarManager[i].getToolBar());
ToolBar toolBar = toolBarManager[i].getToolBar();
for (int j = 0; j < toolBar.getWidgetSize(); j++) {
Widget widget = toolBar.getWidget(j);
resultToolbar.addWidget(widget);
}
}
toolBarPane.populateBean(resultToolbar);
}

Loading…
Cancel
Save