|
|
|
@ -14,11 +14,11 @@ import com.fr.design.mainframe.widget.editors.ImgBackgroundEditor;
|
|
|
|
|
import com.fr.design.mainframe.widget.editors.ShortCutTextEditor; |
|
|
|
|
import com.fr.design.mainframe.widget.renderer.FontCellRenderer; |
|
|
|
|
import com.fr.design.mainframe.widget.renderer.IconCellRenderer; |
|
|
|
|
import com.fr.design.utils.DesignUtils; |
|
|
|
|
import com.fr.form.parameter.FormSubmitButton; |
|
|
|
|
import com.fr.form.ui.Button; |
|
|
|
|
import com.fr.form.ui.FreeButton; |
|
|
|
|
import com.fr.general.Background; |
|
|
|
|
|
|
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
|
import com.fr.stable.core.PropertyChangeAdapter; |
|
|
|
|
|
|
|
|
@ -29,7 +29,6 @@ import java.awt.AlphaComposite;
|
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.Color; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.awt.Font; |
|
|
|
|
import java.awt.Graphics; |
|
|
|
|
import java.awt.Graphics2D; |
|
|
|
|
import java.awt.geom.Rectangle2D; |
|
|
|
@ -41,14 +40,13 @@ import java.beans.IntrospectionException;
|
|
|
|
|
*/ |
|
|
|
|
public class XButton extends XWidgetCreator { |
|
|
|
|
|
|
|
|
|
public final static Background DEFAULTBG = new GradientBackground(new Color(247,247,247),new Color(210,210,210), GradientBackground.TOP2BOTTOM); |
|
|
|
|
public final static Font DEFAULTFT = new Font("Song_TypeFace",0,12); |
|
|
|
|
public final static Background DEFAULTBG = new GradientBackground(new Color(247, 247, 247), new Color(210, 210, 210), GradientBackground.TOP2BOTTOM); |
|
|
|
|
public final static Color DEFAULTFOREGROUNDCOLOR = Color.BLACK; |
|
|
|
|
private Background bg; |
|
|
|
|
private UILabel contentLabel; |
|
|
|
|
private Background bg; |
|
|
|
|
private UILabel contentLabel; |
|
|
|
|
|
|
|
|
|
public XButton(Button widget, Dimension initSize) { |
|
|
|
|
this(new FreeButton(widget),initSize); |
|
|
|
|
this(new FreeButton(widget), initSize); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public XButton(FreeButton widget, Dimension initSize) { |
|
|
|
@ -56,143 +54,146 @@ public class XButton extends XWidgetCreator {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public XButton(FormSubmitButton widget, Dimension initSize) { |
|
|
|
|
super(widget, initSize); |
|
|
|
|
super(widget, initSize); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Background getContentBackground() { |
|
|
|
|
return bg; |
|
|
|
|
} |
|
|
|
|
public Background getContentBackground() { |
|
|
|
|
return bg; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setContentBackground(Background bg) { |
|
|
|
|
this.bg = bg; |
|
|
|
|
} |
|
|
|
|
public void setContentBackground(Background bg) { |
|
|
|
|
this.bg = bg; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public UILabel getContentLabel() { |
|
|
|
|
return contentLabel; |
|
|
|
|
} |
|
|
|
|
public UILabel getContentLabel() { |
|
|
|
|
return contentLabel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setContentLabel(UILabel contentLabel) { |
|
|
|
|
this.contentLabel = contentLabel; |
|
|
|
|
} |
|
|
|
|
public void setContentLabel(UILabel contentLabel) { |
|
|
|
|
this.contentLabel = contentLabel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
*根据下拉框选择返回按钮样式的默认设置或自定义设置列表 |
|
|
|
|
* @return 列表 |
|
|
|
|
* @throws IntrospectionException 抛错 |
|
|
|
|
* 根据下拉框选择返回按钮样式的默认设置或自定义设置列表 |
|
|
|
|
* |
|
|
|
|
* @return 列表 |
|
|
|
|
* @throws IntrospectionException 抛错 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
|
|
|
|
CRPropertyDescriptor[] crp = ((FreeButton) data).isCustomStyle() ? getisCustomStyle() : getisnotCustomStyle(); |
|
|
|
|
|
|
|
|
|
return (CRPropertyDescriptor[]) ArrayUtils.addAll(super.supportedDescriptor(), crp); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected CRPropertyDescriptor creatNonListenerStyle(int i) throws IntrospectionException{ |
|
|
|
|
CRPropertyDescriptor[] crPropertyDescriptors = { |
|
|
|
|
new CRPropertyDescriptor("text", this.data.getClass()).setI18NName( |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Name")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("customStyle", this.data.getClass()).setI18NName( |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_Style")).setEditorClass( |
|
|
|
|
ButtonTypeEditor.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("initialBackground", this.data.getClass()).setEditorClass( |
|
|
|
|
ImgBackgroundEditor.class).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Background_Initial")).putKeyValue( |
|
|
|
|
XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("overBackground", this.data.getClass()).setEditorClass( |
|
|
|
|
ImgBackgroundEditor.class).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Background_Over")).putKeyValue( |
|
|
|
|
XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("clickBackground", this.data.getClass()).setEditorClass( |
|
|
|
|
ImgBackgroundEditor.class).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Background_Click")).putKeyValue( |
|
|
|
|
XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("font", this.data.getClass()).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FR_Font")) |
|
|
|
|
.setEditorClass(FontEditor.class).setRendererClass(FontCellRenderer.class).putKeyValue( |
|
|
|
|
XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("iconName", this.data.getClass()).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon")) |
|
|
|
|
.setEditorClass(IconEditor.class).setRendererClass(IconCellRenderer.class).putKeyValue( |
|
|
|
|
XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("hotkeys", this.data.getClass()) |
|
|
|
|
.setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Hot_keys")) |
|
|
|
|
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") |
|
|
|
|
.setEditorClass(ShortCutTextEditor.class) |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
@Override |
|
|
|
|
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
|
|
|
|
CRPropertyDescriptor[] crp = ((FreeButton) data).isCustomStyle() ? getisCustomStyle() : getisnotCustomStyle(); |
|
|
|
|
|
|
|
|
|
return (CRPropertyDescriptor[]) ArrayUtils.addAll(super.supportedDescriptor(), crp); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected CRPropertyDescriptor creatNonListenerStyle(int i) throws IntrospectionException { |
|
|
|
|
CRPropertyDescriptor[] crPropertyDescriptors = { |
|
|
|
|
new CRPropertyDescriptor("text", this.data.getClass()).setI18NName( |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Name")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("customStyle", this.data.getClass()).setI18NName( |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_Style")).setEditorClass( |
|
|
|
|
ButtonTypeEditor.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("initialBackground", this.data.getClass()).setEditorClass( |
|
|
|
|
ImgBackgroundEditor.class).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Background_Initial")).putKeyValue( |
|
|
|
|
XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("overBackground", this.data.getClass()).setEditorClass( |
|
|
|
|
ImgBackgroundEditor.class).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Background_Over")).putKeyValue( |
|
|
|
|
XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("clickBackground", this.data.getClass()).setEditorClass( |
|
|
|
|
ImgBackgroundEditor.class).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Background_Click")).putKeyValue( |
|
|
|
|
XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("font", this.data.getClass()).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FR_Font")) |
|
|
|
|
.setEditorClass(FontEditor.class).setRendererClass(FontCellRenderer.class).putKeyValue( |
|
|
|
|
XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("iconName", this.data.getClass()).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon")) |
|
|
|
|
.setEditorClass(IconEditor.class).setRendererClass(IconCellRenderer.class).putKeyValue( |
|
|
|
|
XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("hotkeys", this.data.getClass()) |
|
|
|
|
.setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Hot_keys")) |
|
|
|
|
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") |
|
|
|
|
.setEditorClass(ShortCutTextEditor.class) |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
return crPropertyDescriptors[i]; |
|
|
|
|
} |
|
|
|
|
protected CRPropertyDescriptor[] getisCustomStyle() throws IntrospectionException{ |
|
|
|
|
return new CRPropertyDescriptor[]{ |
|
|
|
|
creatNonListenerStyle(0) .setPropertyChangeListener(new PropertyChangeAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void propertyChange() { |
|
|
|
|
setButtonText(((FreeButton) data).getText()); |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
|
|
|
|
|
creatNonListenerStyle(1) .setPropertyChangeListener(new PropertyChangeAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void propertyChange() { |
|
|
|
|
checkButonType(); |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
creatNonListenerStyle(2).setPropertyChangeListener( |
|
|
|
|
new PropertyChangeAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void propertyChange() { |
|
|
|
|
bg = ((FreeButton) data).getInitialBackground(); |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
creatNonListenerStyle(3), |
|
|
|
|
creatNonListenerStyle(4), |
|
|
|
|
creatNonListenerStyle(5) .setPropertyChangeListener( |
|
|
|
|
new PropertyChangeAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void propertyChange() { |
|
|
|
|
FreeButton button = (FreeButton) data; |
|
|
|
|
if (button.getFont() != null) { |
|
|
|
|
contentLabel.setFont(button.getFont().applyResolutionNP( |
|
|
|
|
FontTransformUtil.getDesignerFontResolution())); |
|
|
|
|
contentLabel.setForeground(button.getFont().getForeground()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
creatNonListenerStyle(6), |
|
|
|
|
creatNonListenerStyle(7) |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected CRPropertyDescriptor[] getisCustomStyle() throws IntrospectionException { |
|
|
|
|
return new CRPropertyDescriptor[]{ |
|
|
|
|
creatNonListenerStyle(0).setPropertyChangeListener(new PropertyChangeAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void propertyChange() { |
|
|
|
|
setButtonText(((FreeButton) data).getText()); |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
|
|
|
|
|
creatNonListenerStyle(1).setPropertyChangeListener(new PropertyChangeAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void propertyChange() { |
|
|
|
|
checkButonType(); |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
creatNonListenerStyle(2).setPropertyChangeListener( |
|
|
|
|
new PropertyChangeAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void propertyChange() { |
|
|
|
|
bg = ((FreeButton) data).getInitialBackground(); |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
creatNonListenerStyle(3), |
|
|
|
|
creatNonListenerStyle(4), |
|
|
|
|
creatNonListenerStyle(5).setPropertyChangeListener( |
|
|
|
|
new PropertyChangeAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void propertyChange() { |
|
|
|
|
FreeButton button = (FreeButton) data; |
|
|
|
|
if (button.getFont() != null) { |
|
|
|
|
contentLabel.setFont(button.getFont().applyResolutionNP( |
|
|
|
|
FontTransformUtil.getDesignerFontResolution())); |
|
|
|
|
contentLabel.setForeground(button.getFont().getForeground()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
creatNonListenerStyle(6), |
|
|
|
|
creatNonListenerStyle(7) |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected CRPropertyDescriptor[] getisnotCustomStyle() throws IntrospectionException { |
|
|
|
|
return new CRPropertyDescriptor[]{ |
|
|
|
|
new CRPropertyDescriptor("text", this.data.getClass()) |
|
|
|
|
.setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Name")) |
|
|
|
|
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") |
|
|
|
|
.setPropertyChangeListener(new PropertyChangeAdapter() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void propertyChange() { |
|
|
|
|
setButtonText(((FreeButton) data).getText()); |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
new CRPropertyDescriptor("customStyle", this.data.getClass()).setI18NName( |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_Style")).setEditorClass( |
|
|
|
|
ButtonTypeEditor.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") |
|
|
|
|
.setPropertyChangeListener(new PropertyChangeAdapter() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void propertyChange() { |
|
|
|
|
checkButonType(); |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
new CRPropertyDescriptor("iconName", this.data.getClass()).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon")) |
|
|
|
|
.setEditorClass(IconEditor.class).setRendererClass(IconCellRenderer.class).putKeyValue( |
|
|
|
|
XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("hotkeys", this.data.getClass()).setI18NName( |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Hot_keys")) |
|
|
|
|
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") |
|
|
|
|
.setEditorClass(ShortCutTextEditor.class) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
return new CRPropertyDescriptor[]{ |
|
|
|
|
new CRPropertyDescriptor("text", this.data.getClass()) |
|
|
|
|
.setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Name")) |
|
|
|
|
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") |
|
|
|
|
.setPropertyChangeListener(new PropertyChangeAdapter() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void propertyChange() { |
|
|
|
|
setButtonText(((FreeButton) data).getText()); |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
new CRPropertyDescriptor("customStyle", this.data.getClass()).setI18NName( |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_Style")).setEditorClass( |
|
|
|
|
ButtonTypeEditor.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") |
|
|
|
|
.setPropertyChangeListener(new PropertyChangeAdapter() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void propertyChange() { |
|
|
|
|
checkButonType(); |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
new CRPropertyDescriptor("iconName", this.data.getClass()).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon")) |
|
|
|
|
.setEditorClass(IconEditor.class).setRendererClass(IconCellRenderer.class).putKeyValue( |
|
|
|
|
XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
|
|
|
|
new CRPropertyDescriptor("hotkeys", this.data.getClass()).setI18NName( |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Hot_keys")) |
|
|
|
|
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") |
|
|
|
|
.setEditorClass(ShortCutTextEditor.class) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected JComponent initEditor() { |
|
|
|
|
if (editor == null) { |
|
|
|
@ -202,110 +203,114 @@ public class XButton extends XWidgetCreator {
|
|
|
|
|
return editor; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected UILabel initContentLabel() { |
|
|
|
|
return new UILabel(); |
|
|
|
|
} |
|
|
|
|
protected UILabel initContentLabel() { |
|
|
|
|
return new UILabel(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void paintComponent(Graphics g) { |
|
|
|
|
super.paintComponent(g); |
|
|
|
|
@Override |
|
|
|
|
public void paintComponent(Graphics g) { |
|
|
|
|
super.paintComponent(g); |
|
|
|
|
|
|
|
|
|
//不可见时,按钮.4f透明
|
|
|
|
|
AlphaComposite composite = this.data.isVisible() ? (AlphaComposite)((Graphics2D)g).getComposite() : AlphaComposite.getInstance(AlphaComposite.SRC_OVER,HALF_OPACITY); |
|
|
|
|
((Graphics2D)g).setComposite(composite); |
|
|
|
|
Dimension panelSize = (contentLabel).getSize(); |
|
|
|
|
if(bg != null) { |
|
|
|
|
bg.paint(g, new Rectangle2D.Double(0, 0, panelSize.getWidth(), panelSize.getHeight())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setButtonText(String text) { |
|
|
|
|
contentLabel.setText(text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void checkButonType() { |
|
|
|
|
UILabel l = contentLabel; |
|
|
|
|
FreeButton button = (FreeButton) data; |
|
|
|
|
|
|
|
|
|
if (!button.isCustomStyle()) { |
|
|
|
|
l.setBorder(BorderFactory.createLineBorder(new Color(148, 148, 148))); |
|
|
|
|
bg = DEFAULTBG; |
|
|
|
|
contentLabel.setFont(DEFAULTFT); |
|
|
|
|
AlphaComposite composite = this.data.isVisible() ? (AlphaComposite) ((Graphics2D) g).getComposite() : AlphaComposite.getInstance(AlphaComposite.SRC_OVER, HALF_OPACITY); |
|
|
|
|
((Graphics2D) g).setComposite(composite); |
|
|
|
|
Dimension panelSize = (contentLabel).getSize(); |
|
|
|
|
if (bg != null) { |
|
|
|
|
bg.paint(g, new Rectangle2D.Double(0, 0, panelSize.getWidth(), panelSize.getHeight())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setButtonText(String text) { |
|
|
|
|
contentLabel.setText(text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void checkButonType() { |
|
|
|
|
UILabel l = contentLabel; |
|
|
|
|
FreeButton button = (FreeButton) data; |
|
|
|
|
|
|
|
|
|
if (!button.isCustomStyle()) { |
|
|
|
|
l.setBorder(BorderFactory.createLineBorder(new Color(148, 148, 148))); |
|
|
|
|
bg = DEFAULTBG; |
|
|
|
|
contentLabel.setFont(DesignUtils.getDefaultGUIFont()); |
|
|
|
|
contentLabel.setForeground(DEFAULTFOREGROUNDCOLOR); |
|
|
|
|
editor.setLayout(new BorderLayout()); |
|
|
|
|
editor.add(l, BorderLayout.CENTER); |
|
|
|
|
} else { |
|
|
|
|
l.setBorder(null); |
|
|
|
|
editor.setLayout(new BorderLayout()); |
|
|
|
|
editor.add(l,BorderLayout.CENTER); |
|
|
|
|
editor.add(l, BorderLayout.CENTER); |
|
|
|
|
} else { |
|
|
|
|
l.setBorder(null); |
|
|
|
|
editor.setLayout(new BorderLayout()); |
|
|
|
|
editor.add(l, BorderLayout.CENTER); |
|
|
|
|
if (button.getFont() != null) { |
|
|
|
|
contentLabel.setFont(button.getFont().applyResolutionNP( |
|
|
|
|
FontTransformUtil.getDesignerFontResolution())); |
|
|
|
|
FontTransformUtil.getDesignerFontResolution())); |
|
|
|
|
contentLabel.setForeground(button.getFont().getForeground()); |
|
|
|
|
} |
|
|
|
|
l.setBounds(0, 0, button.getButtonWidth() == 0 ? this.getWidth() : button.getButtonWidth(), button |
|
|
|
|
.getButtonHeight() == 0 ? this.getHeight() : button.getButtonHeight()); |
|
|
|
|
bg = button.getInitialBackground(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
l.setBounds(0, 0, button.getButtonWidth() == 0 ? this.getWidth() : button.getButtonWidth(), button |
|
|
|
|
.getButtonHeight() == 0 ? this.getHeight() : button.getButtonHeight()); |
|
|
|
|
bg = button.getInitialBackground(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void initXCreatorProperties() { |
|
|
|
|
super.initXCreatorProperties(); |
|
|
|
|
checkButonType(); |
|
|
|
|
UILabel l = contentLabel; |
|
|
|
|
FreeButton button = (FreeButton) data; |
|
|
|
|
l.setText(button.getText()); |
|
|
|
|
if (button.isCustomStyle() && button.getFont() != null) { |
|
|
|
|
l.setFont(button.getFont().applyResolutionNP(FontTransformUtil.getDesignerFontResolution())); |
|
|
|
|
l.setForeground(button.getFont().getForeground()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
l.setVerticalAlignment(SwingConstants.CENTER); |
|
|
|
|
l.setHorizontalAlignment(SwingConstants.CENTER); |
|
|
|
|
if (button.getButtonHeight() > 0 && button.getButtonWidth() > 0) { |
|
|
|
|
this.setSize(button.getButtonWidth(), button.getButtonHeight()); |
|
|
|
|
l.setSize(button.getButtonWidth(), button.getButtonHeight()); |
|
|
|
|
XLayoutContainer parent; |
|
|
|
|
if ((parent = XCreatorUtils.getParentXLayoutContainer(this)) instanceof XWAbsoluteLayout) { |
|
|
|
|
((XWAbsoluteLayout) parent).toData().setBounds(toData(), getBounds()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
l.setEnabled(button.isEnabled()); |
|
|
|
|
} |
|
|
|
|
protected void initXCreatorProperties() { |
|
|
|
|
super.initXCreatorProperties(); |
|
|
|
|
checkButonType(); |
|
|
|
|
UILabel l = contentLabel; |
|
|
|
|
FreeButton button = (FreeButton) data; |
|
|
|
|
l.setText(button.getText()); |
|
|
|
|
if (button.isCustomStyle() && button.getFont() != null) { |
|
|
|
|
l.setFont(button.getFont().applyResolutionNP(FontTransformUtil.getDesignerFontResolution())); |
|
|
|
|
l.setForeground(button.getFont().getForeground()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
l.setVerticalAlignment(SwingConstants.CENTER); |
|
|
|
|
l.setHorizontalAlignment(SwingConstants.CENTER); |
|
|
|
|
if (button.getButtonHeight() > 0 && button.getButtonWidth() > 0) { |
|
|
|
|
this.setSize(button.getButtonWidth(), button.getButtonHeight()); |
|
|
|
|
l.setSize(button.getButtonWidth(), button.getButtonHeight()); |
|
|
|
|
XLayoutContainer parent; |
|
|
|
|
if ((parent = XCreatorUtils.getParentXLayoutContainer(this)) instanceof XWAbsoluteLayout) { |
|
|
|
|
((XWAbsoluteLayout) parent).toData().setBounds(toData(), getBounds()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
l.setEnabled(button.isEnabled()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 初始化按钮的Size |
|
|
|
|
* @return 尺寸 |
|
|
|
|
* |
|
|
|
|
* @return 尺寸 |
|
|
|
|
*/ |
|
|
|
|
public Dimension initEditorSize() { |
|
|
|
|
FreeButton button = (FreeButton) data; |
|
|
|
|
if (checkbutton(button)) { |
|
|
|
|
return new Dimension(button.getButtonWidth(), button.getButtonHeight()); |
|
|
|
|
} |
|
|
|
|
return super.initEditorSize(); |
|
|
|
|
} |
|
|
|
|
private boolean checkbutton(FreeButton button){ |
|
|
|
|
return (button.isCustomStyle() && button.getButtonHeight() > 0 && button.getButtonWidth() > 0) ; |
|
|
|
|
@Override |
|
|
|
|
public Dimension initEditorSize() { |
|
|
|
|
FreeButton button = (FreeButton) data; |
|
|
|
|
if (checkbutton(button)) { |
|
|
|
|
return new Dimension(button.getButtonWidth(), button.getButtonHeight()); |
|
|
|
|
} |
|
|
|
|
return super.initEditorSize(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean checkbutton(FreeButton button) { |
|
|
|
|
return (button.isCustomStyle() && button.getButtonHeight() > 0 && button.getButtonWidth() > 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String getIconName() { |
|
|
|
|
return "button_16.png"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* data属性改变触发其他操作 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
public void firePropertyChange(){ |
|
|
|
|
FreeButton button = (FreeButton) data; |
|
|
|
|
setButtonText(button.getText()); |
|
|
|
|
checkButonType(); |
|
|
|
|
if (button.getFont() != null) { |
|
|
|
|
contentLabel.setFont(button.getFont().applyResolutionNP( |
|
|
|
|
FontTransformUtil.getDesignerFontResolution())); |
|
|
|
|
contentLabel.setForeground(button.getFont().getForeground()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* data属性改变触发其他操作 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void firePropertyChange() { |
|
|
|
|
FreeButton button = (FreeButton) data; |
|
|
|
|
setButtonText(button.getText()); |
|
|
|
|
checkButonType(); |
|
|
|
|
if (button.getFont() != null) { |
|
|
|
|
contentLabel.setFont(button.getFont().applyResolutionNP( |
|
|
|
|
FontTransformUtil.getDesignerFontResolution())); |
|
|
|
|
contentLabel.setForeground(button.getFont().getForeground()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|