Mata.Li
6 years ago
62 changed files with 568 additions and 342 deletions
@ -0,0 +1,60 @@
|
||||
package com.fr.design.gui.syntax.util; |
||||
|
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* @author: Harrison |
||||
* @date: 2018/08/29 |
||||
* @description: 为 RTextArea 类中的 Action.xxx 准备的国际化匹配文件 |
||||
**/ |
||||
public enum RTextAreaActionI18nMappingUtil { |
||||
|
||||
Action_CollapseAllFolds("Action.CollapseAllFolds","Fine-Design_Basic_Action_CollapseAllFolds_Name","Fine-Design_Basic_Action_CollapseAllFolds_Mnemonic","Fine-Design_Basic_Action_CollapseAllFolds_Desc"), |
||||
Action_CollapseCommentFolds("Action.CollapseCommentFolds","Fine-Design_Basic_Action_CollapseCommentFolds_Name","Fine-Design_Basic_Action_CollapseCommentFolds_Mnemonic","Fine-Design_Basic_Action_CollapseCommentFolds_Desc"), |
||||
Action_Copy("Action.Copy","Fine-Design_Basic_Action_Copy_Name","Fine-Design_Basic_Action_Copy_Mnemonic","Fine-Design_Basic_Action_Copy_Desc"), |
||||
Action_Cut("Action.Cut","Fine-Design_Basic_Action_Cut_Name","Fine-Design_Basic_Action_Cut_Mnemonic","Fine-Design_Basic_Action_Cut_Desc"), |
||||
Action_Delete("Action.Delete","Fine-Design_Basic_Action_Delete_Name","Fine-Design_Basic_Action_Delete_Mnemonic","Fine-Design_Basic_Action_Delete_Desc"), |
||||
Action_ExpandAllFolds("Action.ExpandAllFolds","Fine-Design_Basic_Action_ExpandAllFolds_Name","Fine-Design_Basic_Action_ExpandAllFolds_Mnemonic","Fine-Design_Basic_Action_ExpandAllFolds_Desc"), |
||||
Action_Paste("Action.Paste","Fine-Design_Basic_Action_Paste_Name","Fine-Design_Basic_Action_Paste_Mnemonic","Fine-Design_Basic_Action_Paste_Desc"), |
||||
Action_Redo("Action.Redo","Fine-Design_Basic_Action_Redo_Name","Fine-Design_Basic_Action_Redo_Mnemonic","Fine-Design_Basic_Action_Redo_Desc"), |
||||
Action_SelectAll("Action.SelectAll","Fine-Design_Basic_Action_SelectAll_Name","Fine-Design_Basic_Action_SelectAll_Mnemonic","Fine-Design_Basic_Action_SelectAll_Desc"), |
||||
Action_ToggleCurrentFold("Action.ToggleCurrentFold","Fine-Design_Basic_Action_ToggleCurrentFold_Name","Fine-Design_Basic_Action_ToggleCurrentFold_Mnemonic","Fine-Design_Basic_Action_ToggleCurrentFold_Desc"), |
||||
Action_Undo("Action.Undo","Fine-Design_Basic_Action_Undo_Name","Fine-Design_Basic_Action_Undo_Mnemonic","Fine-Design_Basic_Action_Undo_Desc"); |
||||
|
||||
private String actionRawKey; |
||||
private String actionName; |
||||
private String actionMnemonic; |
||||
private String actionDesc; |
||||
|
||||
RTextAreaActionI18nMappingUtil(String actionRawKey, String actionName, String actionMnemonic, String actionDesc) { |
||||
this.actionRawKey = actionRawKey; |
||||
this.actionName = actionName; |
||||
this.actionMnemonic = actionMnemonic; |
||||
this.actionDesc = actionDesc; |
||||
} |
||||
|
||||
public static String getActionName(String actionKey) { |
||||
for (RTextAreaActionI18nMappingUtil mapping: RTextAreaActionI18nMappingUtil.values()) { |
||||
if (StringUtils.equals(mapping.actionRawKey, actionKey)) { |
||||
return mapping.actionName; |
||||
} |
||||
} |
||||
return actionKey; |
||||
} |
||||
public static String getActionMnemonic(String actionKey) { |
||||
for (RTextAreaActionI18nMappingUtil mapping: RTextAreaActionI18nMappingUtil.values()) { |
||||
if (StringUtils.equals(mapping.actionRawKey, actionKey)) { |
||||
return mapping.actionMnemonic; |
||||
} |
||||
} |
||||
return actionKey; |
||||
} |
||||
public static String getActionDesc(String actionKey) { |
||||
for (RTextAreaActionI18nMappingUtil mapping: RTextAreaActionI18nMappingUtil.values()) { |
||||
if (StringUtils.equals(mapping.actionRawKey, actionKey)) { |
||||
return mapping.actionDesc; |
||||
} |
||||
} |
||||
return actionKey; |
||||
} |
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.fr.design.utils.gui; |
||||
|
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* @author: Harrison |
||||
* @date: 2018/08/28 |
||||
* @description: 为 Function 类的名字做匹配, 从而方便国际化的类 |
||||
**/ |
||||
public enum FunctionClassMappingUtils { |
||||
DataFunction_Sum("Sum", "Fine-Design_DataFunction_Sum"), |
||||
DataFunction_Average("Average","Fine-Design_DataFunction_Average"), |
||||
DataFunction_Max("Max","Fine-Design_DataFunction_Max"), |
||||
DataFunction_Min("Min","Fine-Design_DataFunction_Min"), |
||||
DataFunction_Count("Count","Fine-Design_DataFunction_Count"), |
||||
DataFunction_None("None","Fine-Design_DataFunction_None"); |
||||
|
||||
private final String functionClassName; |
||||
private final String localeKey; |
||||
|
||||
FunctionClassMappingUtils(String functionClassName, String localeKey) { |
||||
this.functionClassName = functionClassName; |
||||
this.localeKey = localeKey; |
||||
} |
||||
|
||||
public String getFunctionClassName() { |
||||
return functionClassName; |
||||
} |
||||
|
||||
public String getLocaleKey() { |
||||
return localeKey; |
||||
} |
||||
|
||||
public static String getLocaleKey(String functionClassName) { |
||||
for (FunctionClassMappingUtils value : FunctionClassMappingUtils.values()) { |
||||
if (StringUtils.equals(value.getFunctionClassName(), functionClassName)) { |
||||
return value.getLocaleKey(); |
||||
} |
||||
} |
||||
return functionClassName; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,170 @@
|
||||
package com.fr.poly; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.chart.BaseChart; |
||||
import com.fr.base.chart.BaseChartGetter; |
||||
import com.fr.base.chart.BaseChartNameID; |
||||
import com.fr.base.vcs.DesignerMode; |
||||
import com.fr.design.ChartTypeInterfaceManager; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.itooltip.MultiLineToolTip; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.dnd.SerializableTransferable; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.report.poly.PolyECBlock; |
||||
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JFrame; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JToolBar; |
||||
import javax.swing.JToolTip; |
||||
import javax.swing.SwingConstants; |
||||
import javax.swing.UIManager; |
||||
import javax.swing.UnsupportedLookAndFeelException; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Dimension; |
||||
import java.awt.datatransfer.Transferable; |
||||
import java.awt.dnd.DnDConstants; |
||||
import java.awt.dnd.DragGestureEvent; |
||||
import java.awt.dnd.DragGestureListener; |
||||
import java.awt.dnd.DragSource; |
||||
import java.awt.dnd.DragSourceDragEvent; |
||||
import java.awt.dnd.DragSourceDropEvent; |
||||
import java.awt.dnd.DragSourceEvent; |
||||
import java.awt.dnd.DragSourceListener; |
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 拖动聚合块的那个竖的动作条 |
||||
* |
||||
* @editor zhou |
||||
* @since 2012-3-23下午3:42:10 |
||||
*/ |
||||
public class PolyComponentsBar extends JToolBar { |
||||
private SerIcon[] serIcons; |
||||
private static final int MAX_BAR_NUM = 15; |
||||
|
||||
public PolyComponentsBar() { |
||||
setOrientation(SwingConstants.VERTICAL); |
||||
setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 4)); |
||||
setFloatable(false); |
||||
setBackground(UIConstants.TOOLBARUI_BACKGROUND); |
||||
setLayout(FRGUIPaneFactory.create1ColumnGridLayout()); |
||||
BaseChartNameID[] typeName = BaseChartGetter.getStaticAllChartBaseNames(); |
||||
int typeLen = typeName.length < MAX_BAR_NUM ? typeName.length : MAX_BAR_NUM; |
||||
serIcons = new SerIcon[typeLen + 1]; |
||||
serIcons[0] = new SerIcon( |
||||
PolyECBlock.class, |
||||
Toolkit.i18nText("Fine-Design_Report_Poly_Report_Block"), |
||||
"com/fr/design/images/poly/toolbar/Poly-Report_Block.png" |
||||
); |
||||
this.add(serIcons[0]); |
||||
for (int i = 0; i < typeLen; i++) { |
||||
BaseChart[] rowChart = BaseChartGetter.getStaticChartTypes(typeName[i].getPlotID()); |
||||
String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(typeName[i].getPlotID()); |
||||
serIcons[i + 1] = new SerIcon(rowChart[0], Toolkit.i18nText(typeName[i].getName()), iconPath); |
||||
this.add(serIcons[i + 1]); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 设置是否可用状态 |
||||
*/ |
||||
public void checkEnable() { |
||||
for (SerIcon serIcon : serIcons) { |
||||
serIcon.setEnabled(!DesignerMode.isAuthorityEditing()); |
||||
} |
||||
} |
||||
|
||||
private class SerIcon extends UIButton implements DragGestureListener, DragSourceListener { |
||||
private DragSource dragSource; |
||||
private Serializable serializable; |
||||
|
||||
/** |
||||
* @param serializable s |
||||
* @param text 按钮名 |
||||
* @param iconPath 图标路径 |
||||
*/ |
||||
public SerIcon(Serializable serializable, String text, String iconPath) { |
||||
super(BaseUtils.readIcon(iconPath)); |
||||
this.serializable = serializable; |
||||
this.setToolTipText(text); |
||||
this.set4ToolbarButton(); |
||||
dragSource = new DragSource(); |
||||
dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(getIcon().getIconWidth(), getIcon().getIconHeight()); |
||||
} |
||||
|
||||
@Override |
||||
public JToolTip createToolTip() { |
||||
MultiLineToolTip tip = new MultiLineToolTip(); |
||||
tip.setComponent(this); |
||||
tip.setOpaque(false); |
||||
return tip; |
||||
} |
||||
|
||||
@Override |
||||
public void dragGestureRecognized(DragGestureEvent dge) { |
||||
Transferable t = new SerializableTransferable(serializable); |
||||
dragSource.startDrag(dge, DragSource.DefaultCopyDrop, t, this); |
||||
getModel().setArmed(false); |
||||
getModel().setRollover(false); |
||||
repaint(); |
||||
} |
||||
|
||||
@Override |
||||
public void dragEnter(DragSourceDragEvent dsde) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void dragOver(DragSourceDragEvent dsde) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void dropActionChanged(DragSourceDragEvent dsde) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void dragExit(DragSourceEvent dse) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void dragDropEnd(DragSourceDropEvent dsde) { |
||||
|
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 测试下 |
||||
* |
||||
* @param args 参数 |
||||
*/ |
||||
public static void main(String... args) { |
||||
try { |
||||
UIManager.setLookAndFeel(new WindowsLookAndFeel()); |
||||
} catch (UnsupportedLookAndFeelException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
JFrame f = new JFrame(); |
||||
JPanel p = (JPanel) f.getContentPane(); |
||||
p.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
PolyComponentsBar pbp = new PolyComponentsBar(); |
||||
p.add(pbp, BorderLayout.CENTER); |
||||
|
||||
f.setSize(400, 300); |
||||
f.setVisible(true); |
||||
|
||||
} |
||||
} |
@ -1,142 +0,0 @@
|
||||
package com.fr.poly; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.FRContext; |
||||
import com.fr.base.chart.BaseChart; |
||||
import com.fr.base.chart.BaseChartGetter; |
||||
import com.fr.base.chart.BaseChartNameID; |
||||
import com.fr.base.vcs.DesignerMode; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.itooltip.MultiLineToolTip; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.dnd.SerializableTransferable; |
||||
|
||||
import com.fr.report.poly.PolyECBlock; |
||||
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.datatransfer.Transferable; |
||||
import java.awt.dnd.*; |
||||
import java.io.Serializable; |
||||
/** |
||||
* 拖动聚合块的那个竖的动作条 |
||||
* @editor zhou |
||||
* @since 2012-3-23下午3:42:10 |
||||
*/ |
||||
public class PolyComponetsBar extends JToolBar { |
||||
private static Color FOLDER_PANE_BACKGROUND = new Color(214, 223, 247); |
||||
private BaseChartNameID[] typeName = BaseChartGetter.getStaticAllChartBaseNames(); |
||||
private SerIcon[] serIcons; |
||||
private static final int MAX_BAR_NUM = 15; |
||||
|
||||
public PolyComponetsBar() { |
||||
setOrientation(SwingConstants.VERTICAL); |
||||
setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 4)); |
||||
setFloatable(false); |
||||
setBackground(UIConstants.TOOLBARUI_BACKGROUND); |
||||
setLayout(FRGUIPaneFactory.create1ColumnGridLayout()); |
||||
int typeLen = typeName.length < MAX_BAR_NUM ? typeName.length : MAX_BAR_NUM; |
||||
serIcons = new SerIcon[typeLen + 1]; |
||||
serIcons[0] = new SerIcon(PolyECBlock.class, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Poly_Report_Block"), "Fine-Design_Report_Poly_Report_Block"); |
||||
this.add(serIcons[0]); |
||||
for (int i = 0; i < typeLen; i++) { |
||||
BaseChart[] rowChart = BaseChartGetter.getStaticChartTypes(typeName[i].getPlotID()); |
||||
serIcons[i + 1] = new SerIcon(rowChart[0], com.fr.design.i18n.Toolkit.i18nText(typeName[i].getName()), typeName[i].getName()); |
||||
this.add(serIcons[i + 1]); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 设置是否可用状态 |
||||
*/ |
||||
public void checkEnable() { |
||||
for (SerIcon serIcon : serIcons) { |
||||
serIcon.setEnabled(!DesignerMode.isAuthorityEditing()); |
||||
} |
||||
} |
||||
|
||||
private class SerIcon extends UIButton implements DragGestureListener, DragSourceListener { |
||||
private DragSource dragSource; |
||||
private Serializable serializable; |
||||
|
||||
public SerIcon(Serializable serializable, String text, String iconName) { |
||||
super(BaseUtils.readIcon("com/fr/design/images/poly/toolbar/" + iconName + ".png")); |
||||
this.serializable = serializable; |
||||
this.setToolTipText(text); |
||||
this.set4ToolbarButton(); |
||||
dragSource = new DragSource(); |
||||
dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(getIcon().getIconWidth(), getIcon().getIconHeight()); |
||||
} |
||||
|
||||
@Override |
||||
public JToolTip createToolTip() { |
||||
MultiLineToolTip tip = new MultiLineToolTip(); |
||||
tip.setComponent(this); |
||||
tip.setOpaque(false); |
||||
return tip; |
||||
} |
||||
|
||||
@Override |
||||
public void dragGestureRecognized(DragGestureEvent dge) { |
||||
Transferable t = new SerializableTransferable(serializable); |
||||
dragSource.startDrag(dge, DragSource.DefaultCopyDrop, t, this); |
||||
getModel().setArmed(false); |
||||
getModel().setRollover(false); |
||||
repaint(); |
||||
} |
||||
|
||||
@Override |
||||
public void dragEnter(DragSourceDragEvent dsde) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void dragOver(DragSourceDragEvent dsde) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void dropActionChanged(DragSourceDragEvent dsde) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void dragExit(DragSourceEvent dse) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void dragDropEnd(DragSourceDropEvent dsde) { |
||||
|
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 测试下 |
||||
* @param args 参数 |
||||
*/ |
||||
public static void main(String... args) { |
||||
try { |
||||
UIManager.setLookAndFeel(new WindowsLookAndFeel()); |
||||
} catch (UnsupportedLookAndFeelException e) { |
||||
FRContext.getLogger().error(e.getMessage(), e); |
||||
} |
||||
JFrame f = new JFrame(); |
||||
JPanel p = (JPanel) f.getContentPane(); |
||||
p.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
PolyComponetsBar pbp = new PolyComponetsBar(); |
||||
p.add(pbp, BorderLayout.CENTER); |
||||
|
||||
f.setSize(400, 300); |
||||
f.setVisible(true); |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue