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. 40
      designer/src/com/fr/design/actions/cell/style/AlignmentAction.java
  3. 76
      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; import com.fr.design.mainframe.ElementCasePane;
public abstract class ButtonGroupAction extends ElementCaseAction{ public abstract class ButtonGroupAction extends ElementCaseAction{
protected Icon[] iconArray; protected Icon[][] iconArray;
protected Integer[] valueArray; protected Integer[] valueArray;
private UIButtonGroup<Integer> group; private UIButtonGroup<Integer> group;
protected ButtonGroupAction(ElementCasePane t, Icon[] iconArray, Integer[] valueArray) { protected ButtonGroupAction(ElementCasePane t, Icon[][] iconArray, Integer[] valueArray) {
super(t); super(t);
this.iconArray = iconArray; this.iconArray = iconArray;
this.valueArray = valueArray; this.valueArray = valueArray;

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

@ -21,20 +21,16 @@ import javax.swing.*;
public class AlignmentAction extends ButtonGroupAction implements StyleActionInterface { public class AlignmentAction extends ButtonGroupAction implements StyleActionInterface {
private static final Icon[] normalBlackIcon = new Icon[]{ 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.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.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.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}; private static final Integer[] valueArray = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT};
public AlignmentAction(ElementCasePane t) { public AlignmentAction(ElementCasePane t) {
super(t, normalBlackIcon, valueArray); super(t, icons, valueArray);
} }
@ -49,24 +45,14 @@ public class AlignmentAction extends ButtonGroupAction implements StyleActionInt
return style.deriveHorizontalAlignment(getSelectedValue()); return style.deriveHorizontalAlignment(getSelectedValue());
} }
/** /**
* 更新Style * 更新Style
* *
* @param style style * @param style style
*/ */
public void updateStyle(Style style) { public void updateStyle(Style style) {
UIButtonGroup<Integer> buttonGroup = createToolBarComponent(); setSelectedIndex(BaseUtils.getAlignment4Horizontal(style));
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);
}
/** /**
* executeActionReturnUndoRecordNeeded * executeActionReturnUndoRecordNeeded

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

@ -21,42 +21,36 @@ import javax.swing.*;
public class ReportFontBoldAction extends AbstractStyleAction implements ToggleButtonUpdateAction { public class ReportFontBoldAction extends AbstractStyleAction implements ToggleButtonUpdateAction {
private UIToggleButton button; private UIToggleButton button;
protected Style style; protected Style style;
private final static Icon blackIcon = BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.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")};
private final static Icon whiteIcon = BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold_white.png");
public ReportFontBoldAction(ElementCasePane t) { public ReportFontBoldAction(ElementCasePane t) {
super(t); super(t);
this.setName(Inter.getLocText("FRFont-bold")); this.setName(Inter.getLocText("FRFont-bold"));
this.setSmallIcon(blackIcon); this.setSmallIcon(icons, true);
} }
/** /**
* 根据按钮状态获取格式 * 根据按钮状态获取格式
* *
* @param style * @param style
* @param defStyle * @param defStyle
* @return * @return
*/ */
@Override @Override
public Style executeStyle(Style style, Style defStyle) { public Style executeStyle(Style style, Style defStyle) {
button = createToolBarComponent(); createToolBarComponent().setSelected(!createToolBarComponent().isSelected());
button.setIcon(getToggleButtonIcon(button.isSelected())); if (createToolBarComponent().isSelected()) {
button.setSelected(!button.isSelected()); setSelectedFont(style);
if (button.isSelected()) { createToolBarComponent().setSelected(false);
setSelectedFont(style); } else {
button.setSelected(false); setUnselectedFont(style);
} else { createToolBarComponent().setSelected(true);
setUnselectedFont(style); }
button.setSelected(true);
}
return this.style; return this.style;
} }
protected Icon getToggleButtonIcon(boolean isSelected) {
return isSelected ? blackIcon : whiteIcon;
}
protected void setSelectedFont(Style style) { protected void setSelectedFont(Style style) {
this.style = StyleUtils.boldReportFont(style); this.style = StyleUtils.boldReportFont(style);
@ -66,22 +60,20 @@ public class ReportFontBoldAction extends AbstractStyleAction implements ToggleB
this.style = StyleUtils.unBoldReportFont(style); this.style = StyleUtils.unBoldReportFont(style);
} }
/** /**
* Update Style. * Update Style.
*/ */
@Override @Override
public void updateStyle(Style style) { public void updateStyle(Style style) {
if (style == null) { if (style == null) {
return; return;
} }
FRFont frFont = style.getFRFont(); FRFont frFont = style.getFRFont();
if (frFont == null) { if (frFont == null) {
return; return;
} }
button = createToolBarComponent(); createToolBarComponent().setSelected(isStyle(frFont));
button.setSelected(isStyle(frFont)); }
button.setIcon(getToggleButtonIcon(!button.isSelected()));
}
protected boolean isStyle(FRFont frFont) { protected boolean isStyle(FRFont frFont) {
return frFont.isBold(); return frFont.isBold();
@ -95,7 +87,7 @@ public class ReportFontBoldAction extends AbstractStyleAction implements ToggleB
@Override @Override
public UIToggleButton createToolBarComponent() { public UIToggleButton createToolBarComponent() {
if (button == null) { if (button == null) {
button = GUICoreUtils.createToolBarComponent(this); button = GUICoreUtils.createToolBarComponentWhiteIcon(this);
button.setEventBannded(true); button.setEventBannded(true);
} }
return button; 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 { 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[] icons = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic_white.png")};
private final static Icon whiteIcon = BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic_white.png");
public ReportFontItalicAction(ElementCasePane t) { public ReportFontItalicAction(ElementCasePane t) {
super(t); super(t);
this.setName(Inter.getLocText("FRFont-italic")); 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); this.style = StyleUtils.unItalicReportFont(style);
} }
protected Icon getToggleButtonIcon(boolean isSelected) {
return isSelected ? blackIcon : whiteIcon;
}
protected boolean isStyle(FRFont frFont) { protected boolean isStyle(FRFont frFont) {
return frFont.isItalic(); 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 { 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[] icons = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline_white.png")};
private final static Icon whiteIcon = BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline_white.png");
public ReportFontUnderlineAction(ElementCasePane t) { public ReportFontUnderlineAction(ElementCasePane t) {
super(t); super(t);
this.setName(Inter.getLocText("FRFont-Underline")); this.setName(Inter.getLocText("FRFont-Underline"));
this.setSmallIcon(blackIcon); this.setSmallIcon(icons, true);
} }
protected void setSelectedFont (Style style) { protected void setSelectedFont (Style style) {
@ -36,9 +35,6 @@ public class ReportFontUnderlineAction extends ReportFontBoldAction {
this.style = StyleUtils.setReportFontUnderline(style, false); this.style = StyleUtils.setReportFontUnderline(style, false);
} }
protected Icon getToggleButtonIcon(boolean isSelected) {
return isSelected ? blackIcon : whiteIcon;
}
protected boolean isStyle(FRFont frFont) { protected boolean isStyle(FRFont frFont) {
return frFont.getUnderline() != Constants.LINE_NONE; 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); this.putValue(Action.SMALL_ICON, smallIcon);
} }
public void setSmallIcon(Icon[] smallIcon, boolean white) {
this.putValue(Action.SMALL_ICON, smallIcon);
}
/** /**
* Returns the mnemonic property setting. * 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] * support icons[normalIcon, selectedIcon]
* @param icons * @param icons
*/ */
@ -67,6 +67,18 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
addMouseListener(getMouseListener()); 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){ public void setGlobalName(String name){
toggleButtonName = 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); imageLayoutComboBox = new UIComboBox(LAYOUT);
initTextRotationCombox(); initTextRotationCombox();
Icon[] hAlignmentIconArray = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.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.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.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/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/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}; Integer[] hAlignment = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT, Integer.valueOf(Constants.DISTRIBUTED), Constants.NULL};
hAlignmentPane = new UIButtonGroup<Integer>(hAlignmentIconArray, hAlignment); 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"), 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; 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