hzzz
7 years ago
24 changed files with 687 additions and 524 deletions
@ -1,114 +0,0 @@
|
||||
/* |
||||
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. |
||||
*/ |
||||
package com.fr.design.actions.edit; |
||||
|
||||
import java.awt.Color; |
||||
|
||||
import javax.swing.SwingUtilities; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.Style; |
||||
import com.fr.design.actions.ElementCaseAction; |
||||
import com.fr.design.actions.utils.ReportActionUtils; |
||||
import com.fr.design.actions.utils.ReportActionUtils.IterAction; |
||||
import com.fr.design.gui.frpane.HyperlinkGroupPane; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.ElementCasePane; |
||||
import com.fr.design.mainframe.HyperlinkGroupPaneActionImpl; |
||||
import com.fr.design.menu.KeySetUtils; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
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; |
||||
|
||||
/** |
||||
* HyperlinkAction. |
||||
*/ |
||||
public class HyperlinkAction extends ElementCaseAction { |
||||
private boolean b; |
||||
|
||||
public HyperlinkAction(ElementCasePane t) { |
||||
super(t); |
||||
this.setMenuKeySet(KeySetUtils.HYPER_LINK); |
||||
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); |
||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/hyperLink.png")); |
||||
} |
||||
|
||||
/** |
||||
* 计算Action, |
||||
* @return 返回是否需要记录undo |
||||
*/ |
||||
public boolean executeActionReturnUndoRecordNeeded() { |
||||
b = true; |
||||
ElementCasePane reportPane = this.getEditingComponent(); |
||||
if (reportPane == null) { |
||||
return false; |
||||
} |
||||
|
||||
final TemplateElementCase report = reportPane.getEditingElementCase(); |
||||
NameJavaScriptGroup nameHyperlinks = getNameJSGroup(reportPane, report); |
||||
final HyperlinkGroupPane pane = DesignerContext.getDesignerFrame().getSelectedJTemplate().getHyperLinkPane(HyperlinkGroupPaneActionImpl.getInstance()); |
||||
pane.populate(nameHyperlinks); |
||||
|
||||
final Selection sel = reportPane.getSelection(); |
||||
BasicDialog dialog = pane.showWindow(SwingUtilities.getWindowAncestor(reportPane)); |
||||
dialog.addDialogActionListener(new DialogActionAdapter() { |
||||
public void doOk() { |
||||
super.doOk(); |
||||
final NameJavaScriptGroup updateNameHyperlinks = pane.updateJSGroup(); |
||||
if (sel instanceof FloatSelection) { |
||||
FloatElement selectedFloatElement = report.getFloatElement(((FloatSelection)sel).getSelectedFloatName()); |
||||
selectedFloatElement.setNameHyperlinkGroup(updateNameHyperlinks); |
||||
} else { |
||||
ReportActionUtils.actionIterateWithCellSelection((CellSelection)sel, report, new 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); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
public void doCancel() { |
||||
b = false; |
||||
} |
||||
}); |
||||
dialog.setVisible(true); |
||||
|
||||
return b; |
||||
} |
||||
|
||||
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; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,99 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.design.actions.UpdateAction; |
||||
import com.fr.design.actions.core.ActionFactory; |
||||
import com.fr.design.file.HistoryTemplateListPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itoolbar.UIToolbar; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.menu.KeySetUtils; |
||||
import com.fr.design.menu.MenuDef; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* 悬浮元素 |
||||
* Created by MoMeak on 2017/7/27. |
||||
*/ |
||||
public class ReportFloatPane extends JPanel { |
||||
|
||||
private static ReportFloatPane THIS; |
||||
private ElementCasePaneDelegate elementCasePaneDelegate; |
||||
private MenuDef insertFloatMenu; |
||||
|
||||
private ReportFloatPane() { |
||||
initComponent(); |
||||
} |
||||
|
||||
public synchronized static final ReportFloatPane getInstance() { |
||||
if (THIS == null) { |
||||
THIS = new ReportFloatPane(); |
||||
} |
||||
return THIS; |
||||
} |
||||
|
||||
private void initComponent() { |
||||
this.setLayout(new BorderLayout()); |
||||
|
||||
UIToolbar topToolBar = new UIToolbar(); |
||||
topToolBar.setLayout(new BorderLayout()); |
||||
insertFloatMenu = createInsertToolBar(); |
||||
topToolBar.add(createButtonUI()); |
||||
topToolBar.setBorder(BorderFactory.createEmptyBorder(2, 10, 2, 0)); |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double[] columnSize = {p, f}; |
||||
double[] rowSize = {p}; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_Add_FloatElement")), topToolBar}, |
||||
}; |
||||
JPanel leftTopPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||
leftTopPane.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 10)); |
||||
this.add(leftTopPane, BorderLayout.NORTH); |
||||
} |
||||
|
||||
private MenuDef createInsertToolBar() { |
||||
MenuDef insertFloatMenu = new MenuDef(); |
||||
insertFloatMenu.setName(KeySetUtils.INSERT_FLOAT.getMenuKeySetName()); |
||||
insertFloatMenu.setTooltip(Inter.getLocText("FR-Designer_T_Insert_Float")); |
||||
insertFloatMenu.setIconPath("com/fr/design/images/control/addPopup.png"); |
||||
JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
||||
elementCasePaneDelegate = (ElementCasePaneDelegate) editingTemplate.getCurrentElementCasePane(); |
||||
UpdateAction[] actions = ActionFactory.createFloatInsertAction(ElementCasePane.class, elementCasePaneDelegate); |
||||
for (int i = 0; i < actions.length; i++) { |
||||
insertFloatMenu.addShortCut(actions[i]); |
||||
} |
||||
return insertFloatMenu; |
||||
|
||||
} |
||||
|
||||
private UIButton createButtonUI() { |
||||
UIButton createdButton = insertFloatMenu.createUIButton(); |
||||
// 此按钮单独抽出,不应使用工具栏外观
|
||||
if (!createdButton.isOpaque()) { |
||||
createdButton.setOpaque(true); |
||||
createdButton.setNormalPainted(true); |
||||
createdButton.setBorderPaintedOnlyWhenPressed(false); |
||||
} |
||||
return createdButton; |
||||
} |
||||
|
||||
|
||||
public static void main(String[] args) { |
||||
// JFrame jf = new JFrame("test");
|
||||
// jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
// JPanel content = (JPanel) jf.getContentPane();
|
||||
// content.setLayout(new BorderLayout());
|
||||
// content.add(ReportFloatPane.getInstance(), BorderLayout.CENTER);
|
||||
// GUICoreUtils.centerWindow(jf);
|
||||
// jf.setSize(250, 400);
|
||||
// jf.setVisible(true);
|
||||
} |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue