plough
7 years ago
14 changed files with 196 additions and 85 deletions
@ -0,0 +1,91 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import com.fr.base.Style; |
||||||
|
import com.fr.design.actions.utils.ReportActionUtils; |
||||||
|
import com.fr.design.designer.TargetComponent; |
||||||
|
import com.fr.design.file.HistoryTemplateListPane; |
||||||
|
import com.fr.design.gui.frpane.HyperlinkGroupPane; |
||||||
|
import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.grid.selection.CellSelection; |
||||||
|
import com.fr.grid.selection.FloatSelection; |
||||||
|
import com.fr.grid.selection.Selection; |
||||||
|
import com.fr.js.NameJavaScriptGroup; |
||||||
|
import com.fr.report.cell.CellElement; |
||||||
|
import com.fr.report.cell.FloatElement; |
||||||
|
import com.fr.report.elementcase.TemplateElementCase; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by plough on 2017/7/26. |
||||||
|
*/ |
||||||
|
public class HyperlinkGroupPaneActionImpl implements HyperlinkGroupPaneActionProvider { |
||||||
|
private static HyperlinkGroupPaneActionProvider instance; |
||||||
|
|
||||||
|
private HyperlinkGroupPaneActionImpl() { |
||||||
|
} |
||||||
|
|
||||||
|
public static HyperlinkGroupPaneActionProvider getInstance() { |
||||||
|
if (instance == null) { |
||||||
|
instance = new HyperlinkGroupPaneActionImpl(); |
||||||
|
} |
||||||
|
return instance; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populate(HyperlinkGroupPane hyperlinkGroupPane, TargetComponent elementCasePane) { |
||||||
|
ElementCasePane reportPane = (ElementCasePane)elementCasePane; |
||||||
|
final TemplateElementCase report = reportPane.getEditingElementCase(); |
||||||
|
NameJavaScriptGroup nameHyperlinks = getNameJSGroup(reportPane, report); |
||||||
|
hyperlinkGroupPane.populate(nameHyperlinks); |
||||||
|
} |
||||||
|
|
||||||
|
private NameJavaScriptGroup getNameJSGroup(ElementCasePane reportPane, final TemplateElementCase report) { |
||||||
|
NameJavaScriptGroup nameHyperlinks = null; |
||||||
|
final Selection sel = reportPane.getSelection(); |
||||||
|
if (sel instanceof FloatSelection) { |
||||||
|
FloatElement selectedFloatElement = report.getFloatElement(((FloatSelection)sel).getSelectedFloatName()); |
||||||
|
nameHyperlinks = selectedFloatElement.getNameHyperlinkGroup(); |
||||||
|
} else { |
||||||
|
CellElement editCellElement = report.getCellElement(((CellSelection)sel).getColumn(), ((CellSelection)sel).getRow()); |
||||||
|
if (editCellElement != null) { |
||||||
|
nameHyperlinks = editCellElement.getNameHyperlinkGroup(); |
||||||
|
} |
||||||
|
} |
||||||
|
return nameHyperlinks; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void saveSettings(HyperlinkGroupPane hyperlinkGroupPane) { |
||||||
|
TargetComponent tc = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); |
||||||
|
if (tc == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
ElementCasePane reportPane = (ElementCasePane)tc; |
||||||
|
final TemplateElementCase report = reportPane.getEditingElementCase(); |
||||||
|
final Selection sel = reportPane.getSelection(); |
||||||
|
final NameJavaScriptGroup updateNameHyperlinks = hyperlinkGroupPane.updateJSGroup(); |
||||||
|
if (sel instanceof FloatSelection) { |
||||||
|
FloatElement selectedFloatElement = report.getFloatElement(((FloatSelection)sel).getSelectedFloatName()); |
||||||
|
selectedFloatElement.setNameHyperlinkGroup(updateNameHyperlinks); |
||||||
|
} else { |
||||||
|
ReportActionUtils.actionIterateWithCellSelection((CellSelection)sel, report, new ReportActionUtils.IterAction() { |
||||||
|
public void dealWith(CellElement editCellElement) { |
||||||
|
Style elementStyle = editCellElement.getStyle(); |
||||||
|
FRFont frFont = elementStyle.getFRFont(); |
||||||
|
if (updateNameHyperlinks.size() > 0) { |
||||||
|
frFont = frFont.applyForeground(Color.blue); |
||||||
|
frFont = frFont.applyUnderline(Constants.LINE_THIN); |
||||||
|
} else { |
||||||
|
frFont = frFont.applyForeground(Color.black); |
||||||
|
frFont = frFont.applyUnderline(Constants.LINE_NONE); |
||||||
|
} |
||||||
|
editCellElement.setStyle(elementStyle.deriveFRFont(frFont)); |
||||||
|
editCellElement.setNameHyperlinkGroup(updateNameHyperlinks); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
package com.fr.design.gui.frpane; |
||||||
|
|
||||||
|
import com.fr.design.designer.TargetComponent; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by plough on 2017/7/26. |
||||||
|
*/ |
||||||
|
public interface HyperlinkGroupPaneActionProvider { |
||||||
|
void populate(HyperlinkGroupPane hyperlinkGroupPane, TargetComponent elementCasePane); |
||||||
|
void saveSettings(HyperlinkGroupPane hyperlinkGroupPane); |
||||||
|
} |
Loading…
Reference in new issue