You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.9 KiB
88 lines
2.9 KiB
8 years ago
|
package com.fr.quickeditor.cellquick;
|
||
|
|
||
|
import com.fr.base.Style;
|
||
8 years ago
|
import com.fr.design.actions.core.ActionFactory;
|
||
|
import com.fr.design.actions.insert.cell.ImageCellAction;
|
||
8 years ago
|
import com.fr.design.dialog.DialogActionAdapter;
|
||
|
import com.fr.design.gui.ibutton.UIButton;
|
||
8 years ago
|
import com.fr.design.gui.ilable.UILabel;
|
||
8 years ago
|
import com.fr.design.layout.TableLayout;
|
||
|
import com.fr.design.layout.TableLayoutHelper;
|
||
8 years ago
|
import com.fr.design.mainframe.DesignerContext;
|
||
|
import com.fr.design.report.SelectImagePane;
|
||
|
import com.fr.general.ComparatorUtils;
|
||
|
import com.fr.general.Inter;
|
||
|
import com.fr.quickeditor.CellQuickEditor;
|
||
|
import com.fr.report.cell.cellattr.CellImage;
|
||
|
|
||
8 years ago
|
import javax.swing.JComponent;
|
||
|
import javax.swing.JPanel;
|
||
|
import java.awt.BorderLayout;
|
||
|
import java.awt.Component;
|
||
|
import java.awt.Dimension;
|
||
8 years ago
|
import java.awt.event.ActionEvent;
|
||
|
import java.awt.event.ActionListener;
|
||
|
|
||
|
/**
|
||
|
* 单元格元素图片编辑器
|
||
8 years ago
|
*
|
||
|
* @author yaoh.wu
|
||
|
* @version 2017年8月7日10点53分
|
||
8 years ago
|
*/
|
||
|
public class CellImageQuickEditor extends CellQuickEditor {
|
||
|
|
||
8 years ago
|
public CellImageQuickEditor() {
|
||
8 years ago
|
super();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public JComponent createCenterBody() {
|
||
8 years ago
|
JPanel content = new JPanel(new BorderLayout());
|
||
8 years ago
|
UIButton editButton = new UIButton(Inter.getLocText("Edit"));
|
||
8 years ago
|
editButton.addActionListener(new ActionListener() {
|
||
8 years ago
|
@Override
|
||
|
public void actionPerformed(ActionEvent e) {
|
||
|
showEditingDialog();
|
||
|
}
|
||
|
});
|
||
8 years ago
|
editButton.setOpaque(false);
|
||
8 years ago
|
content.add(TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
|
||
8 years ago
|
new Component[]{EMPTY_LABEL, editButton}},
|
||
8 years ago
|
new double[]{TableLayout.PREFERRED},
|
||
8 years ago
|
new double[]{TableLayout.PREFERRED, TableLayout.FILL}, HGAP, VGAP), BorderLayout.CENTER);
|
||
8 years ago
|
return content;
|
||
8 years ago
|
}
|
||
|
|
||
|
private void showEditingDialog() {
|
||
|
final SelectImagePane imageEditorPane = new SelectImagePane();
|
||
|
imageEditorPane.populate(cellElement);
|
||
|
final Object oldValue = cellElement.getValue();
|
||
|
final Style oldStyle = cellElement.getStyle();
|
||
|
imageEditorPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
|
||
|
@Override
|
||
|
public void doOk() {
|
||
|
CellImage cellImage = imageEditorPane.update();
|
||
|
if (!ComparatorUtils.equals(cellImage.getImage(), oldValue) || !ComparatorUtils.equals(cellImage.getStyle(), oldStyle)) {
|
||
|
cellElement.setValue(cellImage.getImage());
|
||
|
cellElement.setStyle(cellImage.getStyle());
|
||
|
fireTargetModified();
|
||
|
}
|
||
|
}
|
||
|
}).setVisible(true);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void refreshDetails() {
|
||
|
|
||
|
}
|
||
|
|
||
8 years ago
|
@Override
|
||
|
public boolean isScrollAll() {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
8 years ago
|
@Override
|
||
|
public Object getComboBoxSelected() {
|
||
|
return ActionFactory.createAction(ImageCellAction.class);
|
||
|
}
|
||
9 years ago
|
}
|