|
|
@ -1,6 +1,6 @@ |
|
|
|
package com.fr.design.webattr; |
|
|
|
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.base.vcs.DesignerMode; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
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.dialog.DialogActionAdapter; |
|
|
|
import com.fr.design.gui.core.WidgetOption; |
|
|
|
import com.fr.design.gui.core.WidgetOption; |
|
|
|
import com.fr.form.ui.Widget; |
|
|
|
import com.fr.form.ui.Widget; |
|
|
|
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.form.ui.WidgetInfoConfig; |
|
|
|
import java.awt.Insets; |
|
|
|
import java.awt.Insets; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics; |
|
|
|
|
|
|
|
import java.awt.Image; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseListener; |
|
|
|
import java.awt.event.MouseListener; |
|
|
|
import javax.swing.Icon; |
|
|
|
import javax.swing.Icon; |
|
|
|
|
|
|
|
import javax.swing.ImageIcon; |
|
|
|
|
|
|
|
|
|
|
|
public class ToolBarButton extends UIButton implements MouseListener { |
|
|
|
public class ToolBarButton extends UIButton implements MouseListener { |
|
|
|
private Widget widget; |
|
|
|
private Widget widget; |
|
|
|
private WidgetOption no; |
|
|
|
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) { |
|
|
|
public ToolBarButton(Icon icon, Widget widget) { |
|
|
|
this(null, icon, widget); |
|
|
|
this(null, icon, widget); |
|
|
@ -30,15 +36,30 @@ public class ToolBarButton extends UIButton implements MouseListener { |
|
|
|
public ToolBarButton(String text, Icon icon, Widget widget) { |
|
|
|
public ToolBarButton(String text, Icon icon, Widget widget) { |
|
|
|
super(text, icon); |
|
|
|
super(text, icon); |
|
|
|
this.widget = widget; |
|
|
|
this.widget = widget; |
|
|
|
//直接设置Icon图标
|
|
|
|
if (widget instanceof com.fr.form.ui.Button) { |
|
|
|
setIcon(icon); |
|
|
|
com.fr.form.ui.Button button = (com.fr.form.ui.Button) widget; |
|
|
|
if (icon instanceof LazyIcon) { |
|
|
|
String iconName = button.getIconName(); |
|
|
|
setDisabledIcon(((LazyIcon) icon).disabled()); |
|
|
|
if (StringUtils.isNotEmpty(iconName)) { |
|
|
|
|
|
|
|
Image iimage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconName); |
|
|
|
|
|
|
|
if (iimage != null) { |
|
|
|
|
|
|
|
setIcon(new ImageIcon(iimage)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.addMouseListener(this); |
|
|
|
this.addMouseListener(this); |
|
|
|
setMargin(new Insets(0, 0, 0, 0)); |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 改变按钮的权限细粒度状态 |
|
|
|
* 改变按钮的权限细粒度状态 |
|
|
|