|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
package com.fr.design.webattr; |
|
|
|
|
|
|
|
|
|
import com.fine.theme.icon.LazyIcon; |
|
|
|
|
import com.fine.theme.utils.FineUIScale; |
|
|
|
|
import com.fr.base.vcs.DesignerMode; |
|
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
@ -8,16 +8,22 @@ import com.fr.design.dialog.BasicDialog;
|
|
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
|
import com.fr.design.gui.core.WidgetOption; |
|
|
|
|
import com.fr.form.ui.Widget; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
import com.fr.form.ui.WidgetInfoConfig; |
|
|
|
|
import java.awt.Insets; |
|
|
|
|
import java.awt.Graphics; |
|
|
|
|
import java.awt.Image; |
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
import java.awt.event.MouseListener; |
|
|
|
|
import javax.swing.Icon; |
|
|
|
|
import javax.swing.ImageIcon; |
|
|
|
|
|
|
|
|
|
public class ToolBarButton extends UIButton implements MouseListener { |
|
|
|
|
private Widget widget; |
|
|
|
|
private WidgetOption no; |
|
|
|
|
private final int ICON_WIDTH = FineUIScale.scale(16); |
|
|
|
|
private final int ICON_HEIGHT = FineUIScale.scale(16); |
|
|
|
|
|
|
|
|
|
public ToolBarButton(Icon icon, Widget widget) { |
|
|
|
|
this(null, icon, widget); |
|
|
|
@ -30,15 +36,30 @@ public class ToolBarButton extends UIButton implements MouseListener {
|
|
|
|
|
public ToolBarButton(String text, Icon icon, Widget widget) { |
|
|
|
|
super(text, icon); |
|
|
|
|
this.widget = widget; |
|
|
|
|
//直接设置Icon图标
|
|
|
|
|
setIcon(icon); |
|
|
|
|
if (icon instanceof LazyIcon) { |
|
|
|
|
setDisabledIcon(((LazyIcon) icon).disabled()); |
|
|
|
|
if (widget instanceof com.fr.form.ui.Button) { |
|
|
|
|
com.fr.form.ui.Button button = (com.fr.form.ui.Button) widget; |
|
|
|
|
String iconName = button.getIconName(); |
|
|
|
|
if (StringUtils.isNotEmpty(iconName)) { |
|
|
|
|
Image iimage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconName); |
|
|
|
|
if (iimage != null) { |
|
|
|
|
setIcon(new ImageIcon(iimage)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.addMouseListener(this); |
|
|
|
|
setMargin(new Insets(0, 0, 0, 0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setIcon(Icon icon) { |
|
|
|
|
if (icon instanceof ImageIcon) { |
|
|
|
|
//自定义上传的图标在设计器工具栏显示需要按照16*16进行缩放
|
|
|
|
|
Image originalImage = ((ImageIcon) icon).getImage(); |
|
|
|
|
Image scaledImage = originalImage.getScaledInstance(ICON_WIDTH, ICON_HEIGHT, Image.SCALE_SMOOTH); |
|
|
|
|
icon = new ImageIcon(scaledImage); |
|
|
|
|
} |
|
|
|
|
super.setIcon(icon); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 改变按钮的权限细粒度状态 |
|
|
|
|