|
|
@ -24,6 +24,8 @@ import com.fr.stable.Constants; |
|
|
|
import com.fr.stable.CoreGraphHelper; |
|
|
|
import com.fr.stable.CoreGraphHelper; |
|
|
|
import com.fr.stable.ListMap; |
|
|
|
import com.fr.stable.ListMap; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
import com.fr.transaction.Configurations; |
|
|
|
|
|
|
|
import com.fr.transaction.WorkerFacade; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
@ -39,326 +41,332 @@ import java.awt.geom.Rectangle2D; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* |
|
|
|
|
|
|
|
* carl:自定义Icon编辑 |
|
|
|
* carl:自定义Icon编辑 |
|
|
|
* |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class CustomIconPane extends BasicPane { |
|
|
|
public class CustomIconPane extends BasicPane { |
|
|
|
private String selectedIconName = null; |
|
|
|
private String selectedIconName = null; |
|
|
|
private ListMap iconButtonMap = null; |
|
|
|
private ListMap iconButtonMap = null; |
|
|
|
private JPanel iconPane = null; |
|
|
|
private JPanel iconPane = null; |
|
|
|
private ButtonGroup bg; |
|
|
|
private ButtonGroup bg; |
|
|
|
private UIScrollPane jsPane; |
|
|
|
private UIScrollPane jsPane; |
|
|
|
// 老一次次去拿真麻烦
|
|
|
|
// 老一次次去拿真麻烦
|
|
|
|
private IconManager iconManager = null; |
|
|
|
private IconManager iconManager = null; |
|
|
|
private UIButton removeButton; |
|
|
|
private UIButton removeButton; |
|
|
|
private UIButton editButton; |
|
|
|
private UIButton editButton; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final int THE_WIDTH = 180; |
|
|
|
private static final int THE_WIDTH = 180; |
|
|
|
private static final int HORIZONTAL_COUNT = 6; |
|
|
|
private static final int HORIZONTAL_COUNT = 6; |
|
|
|
private static final int HEIGHT_PER = 29; |
|
|
|
private static final int HEIGHT_PER = 29; |
|
|
|
private static final int GAP = 10; |
|
|
|
private static final int GAP = 10; |
|
|
|
|
|
|
|
|
|
|
|
public CustomIconPane() { |
|
|
|
public CustomIconPane() { |
|
|
|
this.initComponents(); |
|
|
|
this.initComponents(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initComponents() { |
|
|
|
private void initComponents() { |
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
centerPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon"))); |
|
|
|
centerPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon"))); |
|
|
|
JPanel noNamePane = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); |
|
|
|
JPanel noNamePane = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); |
|
|
|
centerPane.add(noNamePane, BorderLayout.CENTER); |
|
|
|
centerPane.add(noNamePane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
|
|
iconPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
|
|
|
iconPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
|
|
|
|
|
|
|
|
|
|
|
// 开始加图标选择按钮
|
|
|
|
// 开始加图标选择按钮
|
|
|
|
initIcons(); |
|
|
|
initIcons(); |
|
|
|
|
|
|
|
|
|
|
|
jsPane = new UIScrollPane(iconPane); |
|
|
|
jsPane = new UIScrollPane(iconPane); |
|
|
|
refreshIconPane(false); |
|
|
|
refreshIconPane(false); |
|
|
|
jsPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
|
|
|
jsPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
|
|
|
|
|
|
|
|
|
|
|
jsPane.setPreferredSize(new Dimension(200, 180)); |
|
|
|
jsPane.setPreferredSize(new Dimension(200,180)); |
|
|
|
noNamePane.add(jsPane); |
|
|
|
noNamePane.add(jsPane); |
|
|
|
|
|
|
|
|
|
|
|
DescriptionTextArea des = new DescriptionTextArea(2); |
|
|
|
DescriptionTextArea des = new DescriptionTextArea(2); |
|
|
|
des.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message1")); |
|
|
|
des.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message1")); |
|
|
|
centerPane.add(des, BorderLayout.SOUTH); |
|
|
|
centerPane.add(des, BorderLayout.SOUTH); |
|
|
|
|
|
|
|
|
|
|
|
this.add(centerPane, BorderLayout.CENTER); |
|
|
|
this.add(centerPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
|
|
JPanel eastPane = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); |
|
|
|
JPanel eastPane = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); |
|
|
|
JPanel buttonPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(1); |
|
|
|
JPanel buttonPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(1); |
|
|
|
|
|
|
|
|
|
|
|
// 增加、删除、编辑按钮
|
|
|
|
// 增加、删除、编辑按钮
|
|
|
|
initAddButton(buttonPane); |
|
|
|
initAddButton(buttonPane); |
|
|
|
initRemoveButton(buttonPane); |
|
|
|
initRemoveButton(buttonPane); |
|
|
|
initEditButton(buttonPane); |
|
|
|
initEditButton(buttonPane); |
|
|
|
|
|
|
|
|
|
|
|
eastPane.add(buttonPane); |
|
|
|
eastPane.add(buttonPane); |
|
|
|
this.add(eastPane, BorderLayout.EAST); |
|
|
|
this.add(eastPane, BorderLayout.EAST); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initIcons() { |
|
|
|
private void initIcons() { |
|
|
|
iconButtonMap = new ListMap(); |
|
|
|
iconButtonMap = new ListMap(); |
|
|
|
iconManager = WidgetInfoConfig.getInstance().getIconManager(); |
|
|
|
iconManager = WidgetInfoConfig.getInstance().getIconManager(); |
|
|
|
bg = new ButtonGroup(); |
|
|
|
bg = new ButtonGroup(); |
|
|
|
Object[] names = iconManager.getIconNames(); |
|
|
|
Object[] names = iconManager.getIconNames(); |
|
|
|
Object name = null; |
|
|
|
Object name = null; |
|
|
|
for (int i = 0; i < names.length; i++) { |
|
|
|
for (int i = 0; i < names.length; i++) { |
|
|
|
name = names[i]; |
|
|
|
name = names[i]; |
|
|
|
if (name == null || !(name instanceof String)) { |
|
|
|
if (name == null || !(name instanceof String)) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
// carl:默认选第一个
|
|
|
|
// carl:默认选第一个
|
|
|
|
if (this.selectedIconName == null) { |
|
|
|
if (this.selectedIconName == null) { |
|
|
|
this.selectedIconName = (String) name; |
|
|
|
this.selectedIconName = (String)name; |
|
|
|
} |
|
|
|
} |
|
|
|
IconButton iconButton = new IconButton((String) name); |
|
|
|
IconButton iconButton = new IconButton((String)name); |
|
|
|
iconButtonMap.put(name, iconButton); |
|
|
|
iconButtonMap.put(name, iconButton); |
|
|
|
iconPane.add(iconButton); |
|
|
|
iconPane.add(iconButton); |
|
|
|
bg.add(iconButton); |
|
|
|
bg.add(iconButton); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initAddButton(JPanel buttonPane) { |
|
|
|
private void initAddButton(JPanel buttonPane) { |
|
|
|
UIButton addButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add")); |
|
|
|
UIButton addButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add")); |
|
|
|
addButton.setPreferredSize(new Dimension(80, 25)); |
|
|
|
addButton.setPreferredSize(new Dimension(80, 25)); |
|
|
|
addButton.addActionListener(new ActionListener() { |
|
|
|
addButton.addActionListener(new ActionListener() { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
final EditIconDialog add = new EditIconDialog(); |
|
|
|
final EditIconDialog add = new EditIconDialog(); |
|
|
|
add.populate(null); |
|
|
|
add.populate(null); |
|
|
|
add.showWindow(SwingUtilities.getWindowAncestor(CustomIconPane.this), new DialogActionAdapter() { |
|
|
|
add.showWindow(SwingUtilities.getWindowAncestor(CustomIconPane.this), new DialogActionAdapter() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void doOk() { |
|
|
|
public void doOk() { |
|
|
|
Icon icon = add.update(); |
|
|
|
Icon icon = add.update(); |
|
|
|
if (iconManager.addIcon(icon, false)) { |
|
|
|
if (iconManager.addIcon(icon, false)) { |
|
|
|
IconButton iconButton = null;//初始化
|
|
|
|
IconButton iconButton = null;//初始化
|
|
|
|
|
|
|
|
|
|
|
|
addIcon(icon, iconButton); |
|
|
|
addIcon(icon, iconButton); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
}else { |
|
|
|
// add failed
|
|
|
|
// add failed
|
|
|
|
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.WARNING_MESSAGE); |
|
|
|
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.WARNING_MESSAGE); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}).setVisible(true); |
|
|
|
}).setVisible(true); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
buttonPane.add(addButton); |
|
|
|
buttonPane.add(addButton); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initRemoveButton(JPanel buttonPane) { |
|
|
|
private void initRemoveButton(JPanel buttonPane) { |
|
|
|
removeButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove")); |
|
|
|
removeButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove")); |
|
|
|
removeButton.setPreferredSize(new Dimension(80, 25)); |
|
|
|
removeButton.setPreferredSize(new Dimension(80, 25)); |
|
|
|
removeButton.addActionListener(new ActionListener() { |
|
|
|
removeButton.addActionListener(new ActionListener() { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
if (iconManager.isSystemIcon(selectedIconName)) { |
|
|
|
if (iconManager.isSystemIcon(selectedIconName)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (iconManager.removeIcon(selectedIconName)) { |
|
|
|
if (iconManager.removeIcon(selectedIconName)) { |
|
|
|
IconButton iconButton = (IconButton)iconButtonMap.get(selectedIconName); |
|
|
|
IconButton iconButton = (IconButton) iconButtonMap.get(selectedIconName); |
|
|
|
iconPane.remove(iconButton); |
|
|
|
iconPane.remove(iconButton); |
|
|
|
iconButtonMap.remove(selectedIconName); |
|
|
|
iconButtonMap.remove(selectedIconName); |
|
|
|
bg.remove(iconButton); |
|
|
|
bg.remove(iconButton); |
|
|
|
selectedIconName = ((IconButton)iconButtonMap.getByIndex(0)).iconName; |
|
|
|
selectedIconName = ((IconButton) iconButtonMap.getByIndex(0)).iconName; |
|
|
|
refreshIconPane(false); |
|
|
|
refreshIconPane(false); |
|
|
|
CustomIconPane.this.validate(); |
|
|
|
CustomIconPane.this.validate(); |
|
|
|
CustomIconPane.this.repaint(); |
|
|
|
CustomIconPane.this.repaint(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// remove failed
|
|
|
|
// remove failed
|
|
|
|
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), |
|
|
|
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
|
|
|
JOptionPane.WARNING_MESSAGE); |
|
|
|
JOptionPane.WARNING_MESSAGE); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
buttonPane.add(removeButton); |
|
|
|
buttonPane.add(removeButton); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initEditButton(JPanel buttonPane) { |
|
|
|
private void initEditButton(JPanel buttonPane) { |
|
|
|
editButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit")); |
|
|
|
editButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit")); |
|
|
|
editButton.setPreferredSize(new Dimension(80, 25)); |
|
|
|
editButton.setPreferredSize(new Dimension(80, 25)); |
|
|
|
editButton.addActionListener(new ActionListener() { |
|
|
|
editButton.addActionListener(new ActionListener() { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
if (iconManager.isSystemIcon(selectedIconName)) { |
|
|
|
if (iconManager.isSystemIcon(selectedIconName)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
Icon oldIcon = null; |
|
|
|
Icon oldIcon = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
oldIcon= iconManager.getIcon(selectedIconName); |
|
|
|
oldIcon = iconManager.getIcon(selectedIconName); |
|
|
|
} catch (CloneNotSupportedException e1) { |
|
|
|
} catch (CloneNotSupportedException e1) { |
|
|
|
// do nothing
|
|
|
|
// do nothing
|
|
|
|
} |
|
|
|
} |
|
|
|
if (oldIcon == null) { |
|
|
|
if (oldIcon == null) { |
|
|
|
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), |
|
|
|
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), |
|
|
|
"Error", |
|
|
|
"Error", |
|
|
|
"Error", |
|
|
|
"Error", |
|
|
|
JOptionPane.ERROR_MESSAGE); |
|
|
|
JOptionPane.ERROR_MESSAGE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final EditIconDialog edit = new EditIconDialog(); |
|
|
|
final EditIconDialog edit = new EditIconDialog(); |
|
|
|
edit.populate(oldIcon); |
|
|
|
edit.populate(oldIcon); |
|
|
|
edit.showWindow(DesignerContext.getDesignerFrame(), new IconDialogActionListener(oldIcon) { |
|
|
|
edit.showWindow(DesignerContext.getDesignerFrame(), new IconDialogActionListener(oldIcon) { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void doOk() { |
|
|
|
public void doOk() { |
|
|
|
iconManager.removeIcon(oldIcon.getName()); |
|
|
|
iconManager.removeIcon(oldIcon.getName()); |
|
|
|
Icon icon = edit.update(); |
|
|
|
Icon icon = edit.update(); |
|
|
|
if (iconManager.addIcon(icon, false)) { |
|
|
|
if (iconManager.addIcon(icon, false)) { |
|
|
|
IconButton iconButton = (IconButton)iconButtonMap.get(oldIcon.getName()); |
|
|
|
IconButton iconButton = (IconButton) iconButtonMap.get(oldIcon.getName()); |
|
|
|
iconPane.remove(iconButton); |
|
|
|
iconPane.remove(iconButton); |
|
|
|
bg.remove(iconButton); |
|
|
|
bg.remove(iconButton); |
|
|
|
|
|
|
|
|
|
|
|
addIcon(icon, iconButton); |
|
|
|
addIcon(icon, iconButton); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// 失败了再弄回去
|
|
|
|
// 失败了再弄回去
|
|
|
|
iconManager.addIcon(oldIcon, true); |
|
|
|
iconManager.addIcon(oldIcon, true); |
|
|
|
// edit failed
|
|
|
|
// edit failed
|
|
|
|
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.WARNING_MESSAGE); |
|
|
|
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.WARNING_MESSAGE); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}).setVisible(true); |
|
|
|
}).setVisible(true); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
buttonPane.add(editButton); |
|
|
|
buttonPane.add(editButton); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void updateButtonPane() { |
|
|
|
private void updateButtonPane() { |
|
|
|
if (editButton == null || removeButton == null){ |
|
|
|
if (editButton == null || removeButton == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (iconManager.isSystemIcon(selectedIconName)) { |
|
|
|
if (iconManager.isSystemIcon(selectedIconName)) { |
|
|
|
editButton.setEnabled(false); |
|
|
|
editButton.setEnabled(false); |
|
|
|
removeButton.setEnabled(false); |
|
|
|
removeButton.setEnabled(false); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
editButton.setEnabled(true); |
|
|
|
editButton.setEnabled(true); |
|
|
|
removeButton.setEnabled(true); |
|
|
|
removeButton.setEnabled(true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected String title4PopupWindow() { |
|
|
|
protected String title4PopupWindow() { |
|
|
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_SelectIcon"); |
|
|
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_SelectIcon"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 添加按钮 |
|
|
|
* 添加按钮 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param icon 图标 |
|
|
|
* @param icon 图标 |
|
|
|
* @param iconButton 按钮 |
|
|
|
* @param iconButton 按钮 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void addIcon(Icon icon,IconButton iconButton){ |
|
|
|
public void addIcon(Icon icon, IconButton iconButton) { |
|
|
|
selectedIconName = icon.getName(); |
|
|
|
selectedIconName = icon.getName(); |
|
|
|
iconButton = new IconButton(icon.getName()); |
|
|
|
iconButton = new IconButton(icon.getName()); |
|
|
|
iconButtonMap.put(icon.getName(), iconButton); |
|
|
|
iconButtonMap.put(icon.getName(), iconButton); |
|
|
|
iconPane.add(iconButton); |
|
|
|
iconPane.add(iconButton); |
|
|
|
bg.add(iconButton); |
|
|
|
bg.add(iconButton); |
|
|
|
refreshIconPane(true); |
|
|
|
refreshIconPane(true); |
|
|
|
CustomIconPane.this.validate(); |
|
|
|
CustomIconPane.this.validate(); |
|
|
|
CustomIconPane.this.repaint(); |
|
|
|
CustomIconPane.this.repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static class IconDialogActionListener extends DialogActionAdapter { |
|
|
|
public static class IconDialogActionListener extends DialogActionAdapter { |
|
|
|
protected Icon oldIcon; |
|
|
|
protected Icon oldIcon; |
|
|
|
|
|
|
|
|
|
|
|
public IconDialogActionListener(Icon oldIcon) { |
|
|
|
public IconDialogActionListener(Icon oldIcon) { |
|
|
|
this.oldIcon = oldIcon; |
|
|
|
this.oldIcon = oldIcon; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void populate(String iconName) { |
|
|
|
public void populate(String iconName) { |
|
|
|
if (iconName == null) { |
|
|
|
if (iconName == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
this.selectedIconName = iconName; |
|
|
|
this.selectedIconName = iconName; |
|
|
|
updateButtonPane(); |
|
|
|
updateButtonPane(); |
|
|
|
this.repaint(); |
|
|
|
this.repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String update() { |
|
|
|
public String update() { |
|
|
|
return selectedIconName; |
|
|
|
//把图标信息入库
|
|
|
|
} |
|
|
|
Configurations.update(new WorkerFacade(WidgetInfoConfig.class) { |
|
|
|
|
|
|
|
@Override |
|
|
|
// 不知道怎么动态布局,就这么傻傻的调一下大小
|
|
|
|
public void run() { |
|
|
|
private void refreshIconPane(boolean down) { |
|
|
|
WidgetInfoConfig.getInstance().setIconManager(IconManager.getIconManager()); |
|
|
|
iconPane.setPreferredSize(new Dimension(THE_WIDTH, (iconButtonMap.size() / HORIZONTAL_COUNT + 1) * HEIGHT_PER + GAP)); |
|
|
|
} |
|
|
|
UIScrollBar jsBar = jsPane.createVerticalScrollBar(); |
|
|
|
}); |
|
|
|
try { |
|
|
|
|
|
|
|
if (down) { |
|
|
|
return selectedIconName; |
|
|
|
// 将滚动条滚到最后
|
|
|
|
} |
|
|
|
jsBar.setValue(jsBar.getMaximum() - jsBar.getVisibleAmount()); |
|
|
|
|
|
|
|
} else { |
|
|
|
// 不知道怎么动态布局,就这么傻傻的调一下大小
|
|
|
|
jsBar.setValue(0); |
|
|
|
private void refreshIconPane(boolean down) { |
|
|
|
} |
|
|
|
iconPane.setPreferredSize(new Dimension(THE_WIDTH, (iconButtonMap.size() / HORIZONTAL_COUNT + 1) * HEIGHT_PER + GAP)); |
|
|
|
} catch (RuntimeException re) { |
|
|
|
UIScrollBar jsBar = jsPane.createVerticalScrollBar(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
if (down) { |
|
|
|
|
|
|
|
// 将滚动条滚到最后
|
|
|
|
|
|
|
|
jsBar.setValue(jsBar.getMaximum() - jsBar.getVisibleAmount()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
jsBar.setValue(0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (RuntimeException re) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
updateButtonPane(); |
|
|
|
updateButtonPane(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class IconButton extends JToggleButton implements ActionListener{ |
|
|
|
private class IconButton extends JToggleButton implements ActionListener { |
|
|
|
private String iconName; |
|
|
|
private String iconName; |
|
|
|
private Image iconImage = null; |
|
|
|
private Image iconImage = null; |
|
|
|
private static final int ICON_BUTTON_SIZE = 24; |
|
|
|
private static final int ICON_BUTTON_SIZE = 24; |
|
|
|
private static final int ICON_X = 4; |
|
|
|
private static final int ICON_X = 4; |
|
|
|
private static final int ICON_Y = 4; |
|
|
|
private static final int ICON_Y = 4; |
|
|
|
public IconButton(String name) { |
|
|
|
|
|
|
|
this.iconName = name; |
|
|
|
public IconButton(String name) { |
|
|
|
this.addActionListener(this); |
|
|
|
this.iconName = name; |
|
|
|
|
|
|
|
this.addActionListener(this); |
|
|
|
this.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
|
|
|
this.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
|
|
|
this.setBorder(null); |
|
|
|
this.setBorder(null); |
|
|
|
this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(name); |
|
|
|
this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(name); |
|
|
|
this.setToolTipText(iconName); |
|
|
|
this.setToolTipText(iconName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void updateUI() { |
|
|
|
public void updateUI() { |
|
|
|
setUI(new BasicButtonUI(){ |
|
|
|
setUI(new BasicButtonUI() { |
|
|
|
public void paint(Graphics g, JComponent c) { |
|
|
|
public void paint(Graphics g, JComponent c) { |
|
|
|
super.paint(g, c); |
|
|
|
super.paint(g, c); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void paintComponent(Graphics g) { |
|
|
|
public void paintComponent(Graphics g) { |
|
|
|
super.paintComponent(g); |
|
|
|
super.paintComponent(g); |
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
// carl:这里缩放显示 16 × 16
|
|
|
|
// carl:这里缩放显示 16 × 16
|
|
|
|
if (iconImage != null) { |
|
|
|
if (iconImage != null) { |
|
|
|
g2d.drawImage(iconImage, ICON_X, ICON_Y, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); |
|
|
|
g2d.drawImage(iconImage, ICON_X, ICON_Y, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); |
|
|
|
} |
|
|
|
} |
|
|
|
if (this.iconName != null && ComparatorUtils.equals(this.iconName, selectedIconName)) { |
|
|
|
if (this.iconName != null && ComparatorUtils.equals(this.iconName, selectedIconName)) { |
|
|
|
g2d.setPaint(Color.RED); |
|
|
|
g2d.setPaint(Color.RED); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
g2d.setPaint(Color.LIGHT_GRAY); |
|
|
|
g2d.setPaint(Color.LIGHT_GRAY); |
|
|
|
} |
|
|
|
} |
|
|
|
GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, IconManager.DEFAULT_ICONWIDTH + 7, |
|
|
|
GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, IconManager.DEFAULT_ICONWIDTH + 7, |
|
|
|
IconManager.DEFAULT_ICONHEIGHT + 7), Constants.LINE_THICK); |
|
|
|
IconManager.DEFAULT_ICONHEIGHT + 7), Constants.LINE_THICK); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
return new Dimension(ICON_BUTTON_SIZE, ICON_BUTTON_SIZE); |
|
|
|
return new Dimension(ICON_BUTTON_SIZE, ICON_BUTTON_SIZE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
CustomIconPane.this.selectedIconName = iconName; |
|
|
|
CustomIconPane.this.selectedIconName = iconName; |
|
|
|
|
|
|
|
|
|
|
|
fireChagneListener(); |
|
|
|
fireChagneListener(); |
|
|
|
updateButtonPane(); |
|
|
|
updateButtonPane(); |
|
|
|
CustomIconPane.this.repaint();// repaint
|
|
|
|
CustomIconPane.this.repaint();// repaint
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void addChangeListener(ChangeListener changeListener) { |
|
|
|
public void addChangeListener(ChangeListener changeListener) { |
|
|
|
this.changeListener = changeListener; |
|
|
|
this.changeListener = changeListener; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -368,18 +376,18 @@ public class CustomIconPane extends BasicPane { |
|
|
|
this.changeListener.stateChanged(evt); |
|
|
|
this.changeListener.stateChanged(evt); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static class EditIconDialog extends BasicPane { |
|
|
|
private static class EditIconDialog extends BasicPane { |
|
|
|
private UITextField nameTextField; |
|
|
|
private UITextField nameTextField; |
|
|
|
private UILabel showImageLabel; |
|
|
|
private UILabel showImageLabel; |
|
|
|
private Image iconImage = null; |
|
|
|
private Image iconImage = null; |
|
|
|
private String oldName = null; |
|
|
|
private String oldName = null; |
|
|
|
|
|
|
|
|
|
|
|
protected EditIconDialog() { |
|
|
|
protected EditIconDialog() { |
|
|
|
init(); |
|
|
|
init(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void init() { |
|
|
|
private void init() { |
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
@ -393,16 +401,17 @@ public class CustomIconPane extends BasicPane { |
|
|
|
nameTextField = new UITextField(20); |
|
|
|
nameTextField = new UITextField(20); |
|
|
|
|
|
|
|
|
|
|
|
browseButton.addActionListener(new ActionListener() { |
|
|
|
browseButton.addActionListener(new ActionListener() { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
onBrowseButtonClicked(); |
|
|
|
onBrowseButtonClicked(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 焦点丢失时看看名称是否已经存在
|
|
|
|
// 焦点丢失时看看名称是否已经存在
|
|
|
|
nameTextField.addFocusListener(new FocusListener() { |
|
|
|
nameTextField.addFocusListener(new FocusListener() { |
|
|
|
public void focusGained(FocusEvent e) { |
|
|
|
public void focusGained(FocusEvent e) { |
|
|
|
// do nothing
|
|
|
|
// do nothing
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void focusLost(FocusEvent e) { |
|
|
|
public void focusLost(FocusEvent e) { |
|
|
|
if (oldName != null && ComparatorUtils.equals(oldName, nameTextField.getText())) { |
|
|
|
if (oldName != null && ComparatorUtils.equals(oldName, nameTextField.getText())) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -419,7 +428,7 @@ public class CustomIconPane extends BasicPane { |
|
|
|
JPanel imagePane = new JPanel(); |
|
|
|
JPanel imagePane = new JPanel(); |
|
|
|
imagePane.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 0)); |
|
|
|
imagePane.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 0)); |
|
|
|
showImageLabel = new UILabel(); |
|
|
|
showImageLabel = new UILabel(); |
|
|
|
showImageLabel.setPreferredSize(new Dimension(20,20)); |
|
|
|
showImageLabel.setPreferredSize(new Dimension(20, 20)); |
|
|
|
imagePane.add(showImageLabel); |
|
|
|
imagePane.add(showImageLabel); |
|
|
|
imagePane.add(browseButton); |
|
|
|
imagePane.add(browseButton); |
|
|
|
Component[][] components = {{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Name") + ":"), nameTextField}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon") + ":"), imagePane}}; |
|
|
|
Component[][] components = {{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Name") + ":"), nameTextField}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon") + ":"), imagePane}}; |
|
|
@ -439,7 +448,7 @@ public class CustomIconPane extends BasicPane { |
|
|
|
// 将图片转化到16 × 16大小
|
|
|
|
// 将图片转化到16 × 16大小
|
|
|
|
Image image = BaseUtils.readImage(path); |
|
|
|
Image image = BaseUtils.readImage(path); |
|
|
|
BufferedImage bufferedImage = CoreGraphHelper.createBufferedImage(IconManager.DEFAULT_ICONWIDTH, |
|
|
|
BufferedImage bufferedImage = CoreGraphHelper.createBufferedImage(IconManager.DEFAULT_ICONWIDTH, |
|
|
|
IconManager.DEFAULT_ICONHEIGHT, BufferedImage.TYPE_INT_ARGB); |
|
|
|
IconManager.DEFAULT_ICONHEIGHT, BufferedImage.TYPE_INT_ARGB); |
|
|
|
Graphics2D g2d = bufferedImage.createGraphics(); |
|
|
|
Graphics2D g2d = bufferedImage.createGraphics(); |
|
|
|
g2d.drawImage(image, 0, 0, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); |
|
|
|
g2d.drawImage(image, 0, 0, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); |
|
|
|
bufferedImage.flush(); |
|
|
|
bufferedImage.flush(); |
|
|
@ -452,29 +461,29 @@ IconManager.DEFAULT_ICONHEIGHT, BufferedImage.TYPE_INT_ARGB); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected String title4PopupWindow() { |
|
|
|
protected String title4PopupWindow() { |
|
|
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Add_Icon"); |
|
|
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Add_Icon"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 用户自定义的只有name 和 imgae两属性, path不要去管
|
|
|
|
// 用户自定义的只有name 和 imgae两属性, path不要去管
|
|
|
|
public void populate(Icon icon) { |
|
|
|
public void populate(Icon icon) { |
|
|
|
if (icon == null) { |
|
|
|
if (icon == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
oldName = icon.getName(); |
|
|
|
oldName = icon.getName(); |
|
|
|
nameTextField.setText(icon.getName()); |
|
|
|
nameTextField.setText(icon.getName()); |
|
|
|
if (icon.getImage() != null) { |
|
|
|
if (icon.getImage() != null) { |
|
|
|
showImageLabel.setIcon(new ImageIcon(icon.getImage())); |
|
|
|
showImageLabel.setIcon(new ImageIcon(icon.getImage())); |
|
|
|
} |
|
|
|
} |
|
|
|
iconImage = icon.getImage(); |
|
|
|
iconImage = icon.getImage(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Icon update() { |
|
|
|
public Icon update() { |
|
|
|
// 有一个是空,都返回null,反正不会添加的
|
|
|
|
// 有一个是空,都返回null,反正不会添加的
|
|
|
|
if (StringUtils.isBlank(nameTextField.getText()) || iconImage == null) { |
|
|
|
if (StringUtils.isBlank(nameTextField.getText()) || iconImage == null) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
return new Icon(nameTextField.getText(), iconImage); |
|
|
|
return new Icon(nameTextField.getText(), iconImage); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|