@ -1,111 +1,134 @@
|
||||
package com.fr.design.actions.cell.style; |
||||
|
||||
import javax.swing.Icon; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.Style; |
||||
import com.fr.base.chart.BaseChartCollection; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.actions.ButtonGroupAction; |
||||
import com.fr.design.actions.utils.ReportActionUtils; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||
import com.fr.general.Inter; |
||||
import com.fr.design.gui.ibutton.UIToggleButton; |
||||
import com.fr.design.mainframe.ElementCasePane; |
||||
import com.fr.general.Inter; |
||||
import com.fr.grid.selection.FloatSelection; |
||||
import com.fr.grid.selection.Selection; |
||||
import com.fr.report.cell.FloatElement; |
||||
import com.fr.report.elementcase.TemplateElementCase; |
||||
import com.fr.stable.Constants; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
|
||||
public class AlignmentAction extends ButtonGroupAction implements StyleActionInterface { |
||||
|
||||
public AlignmentAction(ElementCasePane t, Icon[] iconArray, |
||||
Integer[] valueArray) { |
||||
super(t, iconArray, valueArray); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* executeStyle |
||||
* |
||||
* @param style |
||||
* @param selectedStyle |
||||
* @return style |
||||
*/ |
||||
public Style executeStyle(Style style, Style selectedStyle) { |
||||
return style.deriveHorizontalAlignment(getSelectedValue()); |
||||
} |
||||
|
||||
/** |
||||
* 更新Style |
||||
* |
||||
* @param style style |
||||
*/ |
||||
public void updateStyle(Style style) { |
||||
setSelectedIndex(BaseUtils.getAlignment4Horizontal(style)); |
||||
} |
||||
|
||||
/** |
||||
* executeActionReturnUndoRecordNeeded |
||||
* |
||||
* @return |
||||
*/ |
||||
public boolean executeActionReturnUndoRecordNeeded() { |
||||
ElementCasePane reportPane = this.getEditingComponent(); |
||||
if (reportPane == null) { |
||||
return false; |
||||
} |
||||
|
||||
return ReportActionUtils.executeAction(this, reportPane); |
||||
} |
||||
|
||||
/** |
||||
* update |
||||
*/ |
||||
public void update() { |
||||
super.update(); |
||||
|
||||
//peter:如果当前没有ReportFrame,不需要继续.
|
||||
if (!this.isEnabled()) { |
||||
return; |
||||
} |
||||
|
||||
//got simple cell element from row and column
|
||||
ElementCasePane reportPane = this.getEditingComponent(); |
||||
if (reportPane == null) { |
||||
this.setEnabled(false); |
||||
return; |
||||
} |
||||
Selection cs = reportPane.getSelection(); |
||||
TemplateElementCase tplEC = reportPane.getEditingElementCase(); |
||||
|
||||
if (tplEC != null && cs instanceof FloatSelection) { |
||||
FloatElement selectedFloat = tplEC.getFloatElement(((FloatSelection) cs).getSelectedFloatName()); |
||||
Object value = selectedFloat.getValue(); |
||||
if (value instanceof BaseChartCollection) { |
||||
this.setEnabled(false); |
||||
return; |
||||
} |
||||
} |
||||
this.updateStyle(ReportActionUtils.getCurrentStyle(reportPane)); |
||||
} |
||||
|
||||
/** |
||||
* 创建工具条,且有提示 |
||||
* |
||||
* @return |
||||
*/ |
||||
public UIButtonGroup<Integer> createToolBarComponent() { |
||||
UIButtonGroup<Integer> group = super.createToolBarComponent(); |
||||
if (group != null) { |
||||
group.setForToolBarButtonGroup(true); |
||||
group.setAllToolTips(new String[]{Inter.getLocText("StyleAlignment-Left"), Inter.getLocText("Center"), Inter.getLocText("StyleAlignment-Right")}); |
||||
} |
||||
for (int i = 0; i < 3; i++) { |
||||
group.getButton(i).setRoundBorder(true, UIConstants.ARC); |
||||
group.getButton(i).setBorderPainted(true); |
||||
} |
||||
return group; |
||||
} |
||||
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[] 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); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* executeStyle |
||||
* |
||||
* @param style |
||||
* @param selectedStyle |
||||
* @return style |
||||
*/ |
||||
public Style executeStyle(Style style, Style selectedStyle) { |
||||
return style.deriveHorizontalAlignment(getSelectedValue()); |
||||
} |
||||
|
||||
/** |
||||
* 更新Style |
||||
* |
||||
* @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); |
||||
} |
||||
|
||||
/** |
||||
* executeActionReturnUndoRecordNeeded |
||||
* |
||||
* @return |
||||
*/ |
||||
public boolean executeActionReturnUndoRecordNeeded() { |
||||
ElementCasePane reportPane = this.getEditingComponent(); |
||||
if (reportPane == null) { |
||||
return false; |
||||
} |
||||
|
||||
return ReportActionUtils.executeAction(this, reportPane); |
||||
} |
||||
|
||||
/** |
||||
* update |
||||
*/ |
||||
public void update() { |
||||
super.update(); |
||||
|
||||
//peter:如果当前没有ReportFrame,不需要继续.
|
||||
if (!this.isEnabled()) { |
||||
return; |
||||
} |
||||
|
||||
//got simple cell element from row and column
|
||||
ElementCasePane reportPane = this.getEditingComponent(); |
||||
if (reportPane == null) { |
||||
this.setEnabled(false); |
||||
return; |
||||
} |
||||
Selection cs = reportPane.getSelection(); |
||||
TemplateElementCase tplEC = reportPane.getEditingElementCase(); |
||||
|
||||
if (tplEC != null && cs instanceof FloatSelection) { |
||||
FloatElement selectedFloat = tplEC.getFloatElement(((FloatSelection) cs).getSelectedFloatName()); |
||||
Object value = selectedFloat.getValue(); |
||||
if (value instanceof BaseChartCollection) { |
||||
this.setEnabled(false); |
||||
return; |
||||
} |
||||
} |
||||
this.updateStyle(ReportActionUtils.getCurrentStyle(reportPane)); |
||||
} |
||||
|
||||
/** |
||||
* 创建工具条,且有提示 |
||||
* |
||||
* @return |
||||
*/ |
||||
public UIButtonGroup<Integer> createToolBarComponent() { |
||||
UIButtonGroup<Integer> group = super.createToolBarComponent(); |
||||
if (group != null) { |
||||
group.setForToolBarButtonGroup(true); |
||||
group.setAllToolTips(new String[]{Inter.getLocText("StyleAlignment-Left"), Inter.getLocText("Center"), Inter.getLocText("StyleAlignment-Right")}); |
||||
} |
||||
for (int i = 0; i < 3; i++) { |
||||
group.getButton(i).setRoundBorder(true, UIConstants.ARC); |
||||
group.getButton(i).setBorderPainted(true); |
||||
} |
||||
return group; |
||||
} |
||||
|
||||
} |
Before Width: | Height: | Size: 503 B After Width: | Height: | Size: 461 B |
Before Width: | Height: | Size: 871 B After Width: | Height: | Size: 761 B |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 299 B |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 539 B |
@ -0,0 +1,59 @@
|
||||
package com.fr.design.gui; |
||||
|
||||
import com.fr.design.file.HistoryTemplateListPane; |
||||
import com.fr.design.mainframe.BaseJForm; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
|
||||
/** |
||||
* Created by mengao on 2017/9/22. |
||||
* 单元格超链、图表超链在不同类型模版中,下拉选项不同 |
||||
*/ |
||||
public class HyperlinkFilterHelper { |
||||
|
||||
public static boolean whetherAddHyperlink4cell(String itemName) { |
||||
JTemplate jTemplate = getCurrentEditingTemplate(); |
||||
if (jTemplate == null) { |
||||
return false; |
||||
} |
||||
//先屏蔽掉这个,之后还有别的
|
||||
String[] names = {Inter.getLocText("FR-Hyperlink_Chart_Float")}; |
||||
for (String name : names) { |
||||
if (!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)) { |
||||
return false; |
||||
} |
||||
} |
||||
return whetherAddFormLink(jTemplate, itemName); |
||||
} |
||||
|
||||
public static boolean whetherAddHyperlink4Chart(String itemName) { |
||||
JTemplate jTemplate = getCurrentEditingTemplate(); |
||||
if (jTemplate == null) { |
||||
return false; |
||||
} |
||||
//先屏蔽掉这个,之后还有别的
|
||||
String[] names = {Inter.getLocText("FR-Hyperlink_Chart_Float"), Inter.getLocText("FR-Hyperlink_Chart_Cell")}; |
||||
for (String name : names) { |
||||
if (!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)) { |
||||
if (jTemplate.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB && ComparatorUtils.equals(itemName, names[0])) { |
||||
//表单报表块中图表悬浮元素超链,只屏蔽联动悬浮元素
|
||||
return false; |
||||
} else if (jTemplate.getEditingReportIndex() == BaseJForm.FORM_TAB) { |
||||
//表单图表超链屏蔽掉联动悬浮元素和联动单元格
|
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
return whetherAddFormLink(jTemplate, itemName); |
||||
} |
||||
|
||||
private static JTemplate getCurrentEditingTemplate() { |
||||
return HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
||||
} |
||||
|
||||
private static boolean whetherAddFormLink(JTemplate jTemplate, String itemName) { |
||||
String formName = Inter.getLocText("Hyperlink-Form_link"); |
||||
return !(jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, formName)); |
||||
} |
||||
} |