|
|
|
@ -21,42 +21,36 @@ import javax.swing.*;
|
|
|
|
|
public class ReportFontBoldAction extends AbstractStyleAction implements ToggleButtonUpdateAction { |
|
|
|
|
private UIToggleButton button; |
|
|
|
|
protected Style style; |
|
|
|
|
private final static Icon blackIcon = BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"); |
|
|
|
|
private final static Icon whiteIcon = BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold_white.png"); |
|
|
|
|
private final static Icon[] icons = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold_white.png")}; |
|
|
|
|
|
|
|
|
|
public ReportFontBoldAction(ElementCasePane t) { |
|
|
|
|
super(t); |
|
|
|
|
|
|
|
|
|
this.setName(Inter.getLocText("FRFont-bold")); |
|
|
|
|
this.setSmallIcon(blackIcon); |
|
|
|
|
this.setSmallIcon(icons, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据按钮状态获取格式 |
|
|
|
|
* |
|
|
|
|
* @param style |
|
|
|
|
* @param defStyle |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Style executeStyle(Style style, Style defStyle) { |
|
|
|
|
button = createToolBarComponent(); |
|
|
|
|
button.setIcon(getToggleButtonIcon(button.isSelected())); |
|
|
|
|
button.setSelected(!button.isSelected()); |
|
|
|
|
if (button.isSelected()) { |
|
|
|
|
setSelectedFont(style); |
|
|
|
|
button.setSelected(false); |
|
|
|
|
} else { |
|
|
|
|
setUnselectedFont(style); |
|
|
|
|
button.setSelected(true); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 根据按钮状态获取格式 |
|
|
|
|
* |
|
|
|
|
* @param style |
|
|
|
|
* @param defStyle |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Style executeStyle(Style style, Style defStyle) { |
|
|
|
|
createToolBarComponent().setSelected(!createToolBarComponent().isSelected()); |
|
|
|
|
if (createToolBarComponent().isSelected()) { |
|
|
|
|
setSelectedFont(style); |
|
|
|
|
createToolBarComponent().setSelected(false); |
|
|
|
|
} else { |
|
|
|
|
setUnselectedFont(style); |
|
|
|
|
createToolBarComponent().setSelected(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return this.style; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected Icon getToggleButtonIcon(boolean isSelected) { |
|
|
|
|
return isSelected ? blackIcon : whiteIcon; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void setSelectedFont(Style style) { |
|
|
|
|
this.style = StyleUtils.boldReportFont(style); |
|
|
|
@ -66,22 +60,20 @@ public class ReportFontBoldAction extends AbstractStyleAction implements ToggleB
|
|
|
|
|
this.style = StyleUtils.unBoldReportFont(style); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Update Style. |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void updateStyle(Style style) { |
|
|
|
|
if (style == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
FRFont frFont = style.getFRFont(); |
|
|
|
|
if (frFont == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
button = createToolBarComponent(); |
|
|
|
|
button.setSelected(isStyle(frFont)); |
|
|
|
|
button.setIcon(getToggleButtonIcon(!button.isSelected())); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* Update Style. |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void updateStyle(Style style) { |
|
|
|
|
if (style == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
FRFont frFont = style.getFRFont(); |
|
|
|
|
if (frFont == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
createToolBarComponent().setSelected(isStyle(frFont)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected boolean isStyle(FRFont frFont) { |
|
|
|
|
return frFont.isBold(); |
|
|
|
@ -95,7 +87,7 @@ public class ReportFontBoldAction extends AbstractStyleAction implements ToggleB
|
|
|
|
|
@Override |
|
|
|
|
public UIToggleButton createToolBarComponent() { |
|
|
|
|
if (button == null) { |
|
|
|
|
button = GUICoreUtils.createToolBarComponent(this); |
|
|
|
|
button = GUICoreUtils.createToolBarComponentWhiteIcon(this); |
|
|
|
|
button.setEventBannded(true); |
|
|
|
|
} |
|
|
|
|
return button; |
|
|
|
|