Browse Source

REPORT-4999 设计器界面的小问题-点击靠左或靠右等设置时,之前设置的地方会变成空白再显示

REPORT-4888 设计器交互修改-优化加粗、倾斜、下划线点击触发效果
master
MoMeak 7 years ago
parent
commit
bf588b70c9
  1. 4
      designer/src/com/fr/design/actions/ButtonGroupAction.java
  2. 26
      designer/src/com/fr/design/actions/cell/style/AlignmentAction.java
  3. 24
      designer/src/com/fr/design/actions/cell/style/ReportFontBoldAction.java
  4. 9
      designer/src/com/fr/design/actions/cell/style/ReportFontItalicAction.java
  5. 8
      designer/src/com/fr/design/actions/cell/style/ReportFontUnderlineAction.java
  6. 4
      designer_base/src/com/fr/design/actions/UpdateAction.java
  7. 14
      designer_base/src/com/fr/design/gui/ibutton/UIToggleButton.java
  8. 14
      designer_base/src/com/fr/design/gui/style/AlignmentPane.java
  9. 27
      designer_base/src/com/fr/design/utils/gui/GUICoreUtils.java

4
designer/src/com/fr/design/actions/ButtonGroupAction.java

@ -6,12 +6,12 @@ import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.mainframe.ElementCasePane;
public abstract class ButtonGroupAction extends ElementCaseAction{
protected Icon[] iconArray;
protected Icon[][] iconArray;
protected Integer[] valueArray;
private UIButtonGroup<Integer> group;
protected ButtonGroupAction(ElementCasePane t, Icon[] iconArray, Integer[] valueArray) {
protected ButtonGroupAction(ElementCasePane t, Icon[][] iconArray, Integer[] valueArray) {
super(t);
this.iconArray = iconArray;
this.valueArray = valueArray;

26
designer/src/com/fr/design/actions/cell/style/AlignmentAction.java

@ -21,20 +21,16 @@ import javax.swing.*;
public class AlignmentAction extends ButtonGroupAction implements StyleActionInterface {
private static final Icon[] normalBlackIcon = new Icon[]{
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png")};
private static final Icon[][] icons = new Icon[][]{
{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal_white.png")},
{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal_white.png")},
{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal_white.png")}};
private static final Icon[] toggleWhiteIcon = new Icon[]{
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal_white.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal_white.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal_white.png")};
private static final Integer[] valueArray = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT};
public AlignmentAction(ElementCasePane t) {
super(t, normalBlackIcon, valueArray);
super(t, icons, valueArray);
}
@ -55,17 +51,7 @@ public class AlignmentAction extends ButtonGroupAction implements StyleActionInt
* @param style style
*/
public void updateStyle(Style style) {
UIButtonGroup<Integer> buttonGroup = createToolBarComponent();
int selected = BaseUtils.getAlignment4Horizontal(style);
for (int i = 0; i < normalBlackIcon.length; i++) {
UIToggleButton button = buttonGroup.getButton(i);
Icon currentIcon = button.getIcon();
Icon newIcon = selected == valueArray[i] ? toggleWhiteIcon[i] : normalBlackIcon[i];
if (newIcon != currentIcon) {
button.setIcon(newIcon);
}
}
setSelectedIndex(selected);
setSelectedIndex(BaseUtils.getAlignment4Horizontal(style));
}
/**

24
designer/src/com/fr/design/actions/cell/style/ReportFontBoldAction.java

@ -21,14 +21,13 @@ 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);
}
/**
@ -40,23 +39,18 @@ public class ReportFontBoldAction extends AbstractStyleAction implements ToggleB
*/
@Override
public Style executeStyle(Style style, Style defStyle) {
button = createToolBarComponent();
button.setIcon(getToggleButtonIcon(button.isSelected()));
button.setSelected(!button.isSelected());
if (button.isSelected()) {
createToolBarComponent().setSelected(!createToolBarComponent().isSelected());
if (createToolBarComponent().isSelected()) {
setSelectedFont(style);
button.setSelected(false);
createToolBarComponent().setSelected(false);
} else {
setUnselectedFont(style);
button.setSelected(true);
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);
@ -78,9 +72,7 @@ public class ReportFontBoldAction extends AbstractStyleAction implements ToggleB
if (frFont == null) {
return;
}
button = createToolBarComponent();
button.setSelected(isStyle(frFont));
button.setIcon(getToggleButtonIcon(!button.isSelected()));
createToolBarComponent().setSelected(isStyle(frFont));
}
protected boolean isStyle(FRFont frFont) {
@ -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;

9
designer/src/com/fr/design/actions/cell/style/ReportFontItalicAction.java

@ -17,14 +17,13 @@ import javax.swing.*;
*/
public class ReportFontItalicAction extends ReportFontBoldAction {
private final static Icon blackIcon = BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png");
private final static Icon whiteIcon = BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic_white.png");
private final static Icon[] icons = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic_white.png")};
public ReportFontItalicAction(ElementCasePane t) {
super(t);
this.setName(Inter.getLocText("FRFont-italic"));
this.setSmallIcon(blackIcon);
this.setSmallIcon(icons, true);
}
@ -36,10 +35,6 @@ public class ReportFontItalicAction extends ReportFontBoldAction {
this.style = StyleUtils.unItalicReportFont(style);
}
protected Icon getToggleButtonIcon(boolean isSelected) {
return isSelected ? blackIcon : whiteIcon;
}
protected boolean isStyle(FRFont frFont) {
return frFont.isItalic();
}

8
designer/src/com/fr/design/actions/cell/style/ReportFontUnderlineAction.java

@ -18,14 +18,13 @@ import javax.swing.*;
*/
public class ReportFontUnderlineAction extends ReportFontBoldAction {
private final static Icon blackIcon = BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png");
private final static Icon whiteIcon = BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline_white.png");
private final static Icon[] icons = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline_white.png")};
public ReportFontUnderlineAction(ElementCasePane t) {
super(t);
this.setName(Inter.getLocText("FRFont-Underline"));
this.setSmallIcon(blackIcon);
this.setSmallIcon(icons, true);
}
protected void setSelectedFont (Style style) {
@ -36,9 +35,6 @@ public class ReportFontUnderlineAction extends ReportFontBoldAction {
this.style = StyleUtils.setReportFontUnderline(style, false);
}
protected Icon getToggleButtonIcon(boolean isSelected) {
return isSelected ? blackIcon : whiteIcon;
}
protected boolean isStyle(FRFont frFont) {
return frFont.getUnderline() != Constants.LINE_NONE;

4
designer_base/src/com/fr/design/actions/UpdateAction.java

@ -139,6 +139,10 @@ public abstract class UpdateAction extends ShortCut implements Action {
this.putValue(Action.SMALL_ICON, smallIcon);
}
public void setSmallIcon(Icon[] smallIcon, boolean white) {
this.putValue(Action.SMALL_ICON, smallIcon);
}
/**
* Returns the mnemonic property setting.
*

14
designer_base/src/com/fr/design/gui/ibutton/UIToggleButton.java

@ -48,7 +48,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
}
/**
* 需要反白的按钮接口
* 需要反白的按钮接口(组合按钮情况-UIButtonGroup)
* support icons[normalIcon, selectedIcon]
* @param icons
*/
@ -67,6 +67,18 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
addMouseListener(getMouseListener());
}
/**
* 需要反白的按钮接口(单个按钮情况)-再次点击取消选中状态
* support icons[normalIcon, selectedIcon]
* @param icons
*/
public UIToggleButton(Icon[] icons, boolean needRelease) {
super(icons[0], null, icons[1]);
setSelectedIcon(icons[1]);
setExtraPainted(true);
addMouseListener(getMouseListener());
}
public void setGlobalName(String name){
toggleButtonName = name ;
}

14
designer_base/src/com/fr/design/gui/style/AlignmentPane.java

@ -80,11 +80,15 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO
imageLayoutComboBox = new UIComboBox(LAYOUT);
initTextRotationCombox();
Icon[] hAlignmentIconArray = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment.png")};
Icon[][] hAlignmentIconArray = {{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal_white.png")},
{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal_white.png")},
{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal_white.png")},
{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal.png")},
{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment.png")}};
// BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"),
// BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"),
// BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal.png"),
// BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment.png")};
Integer[] hAlignment = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT, Integer.valueOf(Constants.DISTRIBUTED), Constants.NULL};
hAlignmentPane = new UIButtonGroup<Integer>(hAlignmentIconArray, hAlignment);
hAlignmentPane.setAllToolTips(new String[]{Inter.getLocText("FR-Designer-StyleAlignment_Tooltips_Left"), Inter.getLocText("FR-Designer-StyleAlignment_Tooltips_Center"), Inter.getLocText("FR-Designer-StyleAlignment_Tooltips_Right"),

27
designer_base/src/com/fr/design/utils/gui/GUICoreUtils.java

@ -221,6 +221,33 @@ public abstract class GUICoreUtils{
return (UIToggleButton) object;
}
/**
* 创建工具栏组件-反白icon
* @param updateAction 更新动作
* @return UIToggleButton 按钮
*
*/
public static UIToggleButton createToolBarComponentWhiteIcon(UpdateAction updateAction) {
UIToggleButton button = new UIToggleButton((Icon[]) updateAction.getValue(Action.SMALL_ICON), true);
button.set4ToolbarButton();
Integer mnemonicInteger = (Integer) updateAction.getValue(Action.MNEMONIC_KEY);
if (mnemonicInteger != null) {
button.setMnemonic((char) mnemonicInteger.intValue());
}
button.addActionListener(updateAction);
button.registerKeyboardAction(updateAction, updateAction.getAccelerator(), JComponent.WHEN_IN_FOCUSED_WINDOW);
updateAction.putValue(UIToggleButton.class.getName(), button);
button.setText(StringUtils.EMPTY);
button.setEnabled(updateAction.isEnabled());
button.setToolTipText(ActionFactory.createButtonToolTipText(updateAction));
return button;
}
/**
* 设置一个窗口
*

Loading…
Cancel
Save