Browse Source

REPORT-25645 mac设计器取色器异常

feature/big-screen
vito 5 years ago
parent
commit
d6b790249c
  1. 452
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java
  2. 78
      designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java
  3. 15
      designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java
  4. 462
      designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java
  5. 2
      designer-base/src/main/java/com/fr/start/BaseDesigner.java

452
designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java

@ -1,19 +1,5 @@
package com.fr.design.gui.ibutton; package com.fr.design.gui.ibutton;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameListener;
@ -21,231 +7,223 @@ import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ipoppane.PopupHider; import com.fr.design.gui.ipoppane.PopupHider;
import com.fr.general.ComparatorUtils;
import com.fr.design.style.color.ColorControlWindow; import com.fr.design.style.color.ColorControlWindow;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class UIColorButton extends UIButton implements PopupHider, UIObserver, GlobalNameObserver { public class UIColorButton extends UIButton implements PopupHider, UIObserver, GlobalNameObserver {
private static final int SIZE = 16; private static final int SIZE = 16;
private static final int SIZE_2 = 2; private static final int SIZE_2 = 2;
private static final int SIZE_4 = 4; private static final int SIZE_4 = 4;
private static final int SIZE_6 = 6; private static final int SIZE_6 = 6;
private static final int POPUP_MENU_SHIFT = -70; private static final int POPUP_MENU_SHIFT = -70;
private Color color = Color.BLACK; private Color color = Color.BLACK;
private ColorControlWindow popupWin; private ColorControlWindow popupWin;
private EventListenerList colorChangeListenerList = new EventListenerList(); private EventListenerList colorChangeListenerList = new EventListenerList();
private boolean isEventBanned = false; private boolean isEventBanned = false;
private String colorButtonName = ""; private String colorButtonName = "";
private UIObserverListener uiObserverListener; private UIObserverListener uiObserverListener;
private GlobalNameListener globalNameListener = null; private GlobalNameListener globalNameListener = null;
public UIColorButton() { public UIColorButton() {
this(UIConstants.FONT_ICON); this(UIConstants.FONT_ICON);
} }
public UIColorButton(Icon icon) { public UIColorButton(Icon icon) {
super(icon); super(icon);
setUI(getButtonUI()); setUI(getButtonUI());
addMouseListener(new MouseAdapter() { addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
showPopupMenu(); showPopupMenu();
} }
}); });
iniListener(); iniListener();
} }
private void iniListener() { private void iniListener() {
if (shouldResponseChangeListener()) { if (shouldResponseChangeListener()) {
this.addColorChangeListener(new ChangeListener() { this.addColorChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
if (uiObserverListener == null) { if (uiObserverListener == null) {
return; return;
} }
if (globalNameListener != null && shouldResponseNameListener()) { if (globalNameListener != null && shouldResponseNameListener()) {
globalNameListener.setGlobalName(colorButtonName); globalNameListener.setGlobalName(colorButtonName);
} }
uiObserverListener.doChange(); uiObserverListener.doChange();
} }
}); });
} }
} }
private UIButtonUI getButtonUI() { private UIButtonUI getButtonUI() {
return new UIButtonUI() { return new UIButtonUI() {
@Override @Override
protected void paintIcon(Graphics g, JComponent c) { protected void paintIcon(Graphics g, JComponent c) {
super.paintIcon(g, c); super.paintIcon(g, c);
AbstractButton b = (AbstractButton) c; AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel(); ButtonModel model = b.getModel();
if (model.isEnabled()) { if (model.isEnabled()) {
g.setColor(UIColorButton.this.getColor()); g.setColor(UIColorButton.this.getColor());
} else { } else {
g.setColor(new Color(Utils.filterRGB(UIColorButton.this.getColor().getRGB(), 50))); g.setColor(new Color(Utils.filterRGB(UIColorButton.this.getColor().getRGB(), 50)));
} }
g.fillRect((b.getWidth() - SIZE) / SIZE_2, b.getHeight() - SIZE_6, SIZE, SIZE_4); g.fillRect((b.getWidth() - SIZE) / SIZE_2, b.getHeight() - SIZE_6, SIZE, SIZE_4);
} }
}; };
} }
public void setEventBanned(boolean isEventBanned) { public void setEventBanned(boolean isEventBanned) {
this.isEventBanned = isEventBanned; this.isEventBanned = isEventBanned;
} }
public void setGlobalName(String name) { public void setGlobalName(String name) {
colorButtonName = name; colorButtonName = name;
} }
public Color getColor() { public Color getColor() {
return color; return color;
} }
public void setColor(Color color) { public void setColor(Color color) {
if (ComparatorUtils.equals(this.color, color)) { if (ComparatorUtils.equals(this.color, color)) {
return; return;
} }
this.color = color; this.color = color;
hidePopupMenu(); hidePopupMenu();
fireColorStateChanged(); fireColorStateChanged();
} }
private void showPopupMenu() { private void showPopupMenu() {
if (isEventBanned) { if (isEventBanned) {
return; return;
} }
if (popupWin != null && popupWin.isVisible()) { if (popupWin != null && popupWin.isVisible()) {
hidePopupMenu(); hidePopupMenu();
return; return;
} }
if (!this.isEnabled()) { if (!this.isEnabled()) {
return; return;
} }
popupWin = this.getColorControlWindow(); popupWin = this.getColorControlWindow();
GUICoreUtils.showPopupMenu(popupWin, this, POPUP_MENU_SHIFT, this.getSize().height); GUICoreUtils.showPopupMenu(popupWin, this, POPUP_MENU_SHIFT, this.getSize().height);
} }
/** /**
* 隐藏popupmenu * 隐藏popupmenu
*/ */
public void hidePopupMenu() { public void hidePopupMenu() {
if (popupWin != null) { if (popupWin != null) {
popupWin.setVisible(false); popupWin.setVisible(false);
repaint(); }
} popupWin = null;
repaint();
popupWin = null; }
}
private ColorControlWindow getColorControlWindow() {
private ColorControlWindow getColorControlWindow() { //find parant.
//find parant. if (this.popupWin == null) {
if (this.popupWin == null) { this.popupWin = new ColorControlWindow(UIColorButton.this) {
this.popupWin = new ColorControlWindow(UIColorButton.this) { @Override
@Override protected void colorChanged() {
protected void colorChanged() { UIColorButton.this.setColor(this.getColor());
UIColorButton.this.setColor(this.getColor()); }
}
};
}; }
}
return popupWin;
return popupWin; }
}
/**
/** * 添加监听
* 添加监听 *
* * @param changeListener 监听列表
* @param changeListener 监听列表 */
*/ public void addColorChangeListener(ChangeListener changeListener) {
public void addColorChangeListener(ChangeListener changeListener) { colorChangeListenerList.add(ChangeListener.class, changeListener);
colorChangeListenerList.add(ChangeListener.class, changeListener); }
}
/**
/** * 移除监听
* 移除监听 * Removes an old ColorChangeListener.
* Removes an old ColorChangeListener. *
* @param changeListener 监听列表 * @param changeListener 监听列表
*/ */
public void removeColorChangeListener(ChangeListener changeListener) { public void removeColorChangeListener(ChangeListener changeListener) {
colorChangeListenerList.remove(ChangeListener.class, changeListener); colorChangeListenerList.remove(ChangeListener.class, changeListener);
} }
/** /**
* 颜色状态改变 * 颜色状态改变
*/ */
public void fireColorStateChanged() { public void fireColorStateChanged() {
Object[] listeners = colorChangeListenerList.getListenerList(); Object[] listeners = colorChangeListenerList.getListenerList();
ChangeEvent e = null; ChangeEvent e = null;
for (int i = listeners.length - 2; i >= 0; i -= 2) { for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == ChangeListener.class) { if (listeners[i] == ChangeListener.class) {
if (e == null) { if (e == null) {
e = new ChangeEvent(this); e = new ChangeEvent(this);
} }
((ChangeListener) listeners[i + 1]).stateChanged(e); ((ChangeListener) listeners[i + 1]).stateChanged(e);
} }
} }
} }
/** /**
* 注册状态改变监听 * 注册状态改变监听
* *
* @param listener 观察者监听事件 * @param listener 观察者监听事件
*/ */
public void registerChangeListener(UIObserverListener listener) { public void registerChangeListener(UIObserverListener listener) {
uiObserverListener = listener; uiObserverListener = listener;
} }
/** /**
* 是否需要响应监听 * 是否需要响应监听
* *
* @return 是否响应 * @return 是否响应
*/ */
public boolean shouldResponseChangeListener() { public boolean shouldResponseChangeListener() {
return true; return true;
} }
/** /**
* 注册监听 * 注册监听
* *
* @param listener 观察者监听事件 * @param listener 观察者监听事件
*/ */
public void registerNameListener(GlobalNameListener listener) { public void registerNameListener(GlobalNameListener listener) {
globalNameListener = listener; globalNameListener = listener;
} }
/** /**
* 是否需要相应 * 是否需要相应
* *
* @return 是否响应 * @return 是否响应
*/ */
public boolean shouldResponseNameListener() { public boolean shouldResponseNameListener() {
return true; return true;
} }
/**
* 主函数
*
* @param args 参数
*/
public static void main(String... args) {
LayoutManager layoutManager = null;
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(layoutManager);
UIColorButton bb = new UIColorButton(UIConstants.FONT_ICON);
bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height);
content.add(bb);
GUICoreUtils.centerWindow(jf);
jf.setSize(400, 400);
jf.setVisible(true);
}
} }

78
designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java

@ -1,40 +1,41 @@
package com.fr.design.style.color; package com.fr.design.style.color;
import java.awt.BorderLayout; import com.fr.design.gui.ipoppane.PopupHider;
import java.awt.Color; import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import com.fr.design.gui.ipoppane.PopupHider; import java.awt.Color;
import com.fr.design.layout.FRGUIPaneFactory;
public abstract class ColorControlWindow extends JPopupMenu { public abstract class ColorControlWindow extends JPopupMenu {
private static final long serialVersionUID = 4317136753151221742L; private static final long serialVersionUID = 4317136753151221742L;
private PopupHider popupHider; private PopupHider popupHider;
private ColorSelectionPopupPane selectionPopupPane; private ColorSelectionPopupPane selectionPopupPane;
protected abstract void colorChanged();
/** protected abstract void colorChanged();
/**
* Constructor. * Constructor.
*/ */
public ColorControlWindow(PopupHider popupHider) { public ColorControlWindow(PopupHider popupHider) {
this(false,popupHider); this(false, popupHider);
} }
/**
/**
* Constructor. * Constructor.
*/ */
public ColorControlWindow(boolean isSupportTransparent, PopupHider popupHider) { public ColorControlWindow(boolean isSupportTransparent, PopupHider popupHider) {
this.initComponents(isSupportTransparent); this.initComponents(isSupportTransparent);
this.popupHider = popupHider; this.popupHider = popupHider;
} }
public Color getColor() { public Color getColor() {
if(selectionPopupPane == null) { if (selectionPopupPane == null) {
return null; return null;
} }
return selectionPopupPane.getColor(); return selectionPopupPane.getColor();
} }
/** /**
@ -52,30 +53,33 @@ public abstract class ColorControlWindow extends JPopupMenu {
this.add(selectionPopupPane, BorderLayout.CENTER); this.add(selectionPopupPane, BorderLayout.CENTER);
this.pack(); this.pack();
} }
class ColorSelectionPopupPane extends NewColorSelectPane { class ColorSelectionPopupPane extends NewColorSelectPane {
private static final long serialVersionUID = 7822856562329146354L; private static final long serialVersionUID = 7822856562329146354L;
public ColorSelectionPopupPane(boolean isSupportTransparent) {
super(isSupportTransparent); public ColorSelectionPopupPane(boolean isSupportTransparent) {
this.addChangeListener(new ChangeListener() { super(isSupportTransparent);
this.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) { @Override
colorChanged(); public void stateChanged(ChangeEvent e) {
} colorChanged();
}); }
});
} }
@Override @Override
protected void doTransparent() { protected void doTransparent() {
popupHider.hidePopupMenu(); popupHider.hidePopupMenu();
super.doTransparent(); super.doTransparent();
} }
@Override
public void customButtonPressed() { @Override
popupHider.hidePopupMenu(); public void customButtonPressed() {
super.customButtonPressed(); popupHider.hidePopupMenu();
} super.customButtonPressed();
}
} }
} }

15
designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java

@ -11,6 +11,8 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.*; import java.awt.*;
import static com.fr.design.i18n.Toolkit.i18nText;
/** /**
* 颜色选择器更多颜色面板 * 颜色选择器更多颜色面板
* *
@ -56,7 +58,7 @@ public class ColorSelectDetailPane extends BasicPane {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_Color"); return i18nText("Fine-Design_Basic_Select_Color");
} }
protected void initComponents() { protected void initComponents() {
@ -65,20 +67,15 @@ public class ColorSelectDetailPane extends BasicPane {
// 颜色选择器面板 // 颜色选择器面板
selectedPanel = new JColorChooser(this.color); selectedPanel = new JColorChooser(this.color);
selectedPanel.setPreferredSize(new Dimension(selectedPanel.getWidth(), SELECT_PANEL_HEIGHT)); selectedPanel.setPreferredSize(new Dimension(selectedPanel.getWidth(), SELECT_PANEL_HEIGHT));
AbstractColorChooserPanel[] choosers = selectedPanel.getChooserPanels();
for (int i = 0; i < choosers.length; i++) {
selectedPanel.removeChooserPanel(choosers[i]);
}
selectedPanel.setPreviewPanel(new JPanel()); selectedPanel.setPreviewPanel(new JPanel());
AbstractColorChooserPanel swatchChooserPanel = new SwatchChooserPanel(); AbstractColorChooserPanel swatchChooserPanel = new SwatchChooserPanel();
AbstractColorChooserPanel customChooserPanel = new CustomChooserPanel(); AbstractColorChooserPanel customChooserPanel = new CustomChooserPanel();
selectedPanel.addChooserPanel(swatchChooserPanel); selectedPanel.setChooserPanels(new AbstractColorChooserPanel[]{swatchChooserPanel, customChooserPanel});
selectedPanel.addChooserPanel(customChooserPanel);
this.add(selectedPanel, BorderLayout.NORTH); this.add(selectedPanel, BorderLayout.NORTH);
// 最近使用面板 // 最近使用面板
recentUsePanel = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Used")); recentUsePanel = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Used"));
RecentUseColorPane recent = new RecentUseColorPane(selectedPanel); RecentUseColorPane recent = new RecentUseColorPane(selectedPanel);
recentUsePanel.add(recent); recentUsePanel.add(recent);
@ -87,7 +84,7 @@ public class ColorSelectDetailPane extends BasicPane {
selectedPanel.setPreviewPanel(new JPanel()); selectedPanel.setPreviewPanel(new JPanel());
// 预览 // 预览
previewPanel = FRGUIPaneFactory.createTitledBorderPaneCenter(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview")); previewPanel = FRGUIPaneFactory.createTitledBorderPaneCenter(i18nText("Fine-Design_Basic_Preview"));
final ColorChooserPreview colorChooserPreview = new ColorChooserPreview(); final ColorChooserPreview colorChooserPreview = new ColorChooserPreview();
ColorSelectionModel model = selectedPanel.getSelectionModel(); ColorSelectionModel model = selectedPanel.getSelectionModel();
model.addChangeListener(new ChangeListener() { model.addChangeListener(new ChangeListener() {

462
designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java

@ -3,15 +3,6 @@
*/ */
package com.fr.design.style.color; package com.fr.design.style.color;
import java.awt.Color;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.Icon;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
@ -20,234 +11,237 @@ import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UICombinationButton; import com.fr.design.gui.ibutton.UICombinationButton;
import com.fr.design.gui.ipoppane.PopupHider; import com.fr.design.gui.ipoppane.PopupHider;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.os.OperatingSystem;
import javax.swing.Icon;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
import java.awt.Color;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
/** /**
* Color select pane2. * Color select pane2.
*/ */
public class UIToolbarColorButton extends UICombinationButton implements PopupHider, ColorSelectable, UIObserver { public class UIToolbarColorButton extends UICombinationButton implements PopupHider, ColorSelectable, UIObserver {
private static final long serialVersionUID = 3220957076370197935L; private static final long serialVersionUID = 3220957076370197935L;
private Color color = null; private Color color = null;
private boolean isCanBeNull = false; private boolean isCanBeNull = false;
private ColorControlWindow popupWin; private ColorControlWindow popupWin;
//color setting action. //color setting action.
private EventListenerList colorChangeListenerList = new EventListenerList(); private EventListenerList colorChangeListenerList = new EventListenerList();
private UIObserverListener uiObserverListener; private UIObserverListener uiObserverListener;
public UIToolbarColorButton(Icon icon) {
public UIToolbarColorButton(Icon icon) { super(new UIColorButton(icon), new UIButton(BaseUtils.readIcon("/com/fr/design/images/gui/popup.gif")));
super(new UIColorButton(icon), new UIButton(BaseUtils.readIcon("/com/fr/design/images/gui/popup.gif"))); getLeftButton().setEventBanned(true);
getLeftButton().setEventBanned(true); getRightButton().addFocusListener(new FocusListener() {
getRightButton().addFocusListener(new FocusListener() {
@Override
@Override public void focusGained(FocusEvent e) {
public void focusGained(FocusEvent e) { }
}
@Override
@Override public void focusLost(FocusEvent e) {
public void focusLost(FocusEvent e) { hidePopupMenu();
hidePopupMenu(); }
} });
}); iniListener();
iniListener(); }
}
private void iniListener() {
private void iniListener() { if (shouldResponseChangeListener()) {
if (shouldResponseChangeListener()) { this.addColorChangeListener(new ChangeListener() {
this.addColorChangeListener(new ChangeListener() { @Override
@Override public void stateChanged(ChangeEvent e) {
public void stateChanged(ChangeEvent e) { if (uiObserverListener == null) {
if (uiObserverListener == null) { return;
return; }
} uiObserverListener.doChange();
uiObserverListener.doChange(); }
} });
}); }
} }
}
@Override
@Override public UIColorButton getLeftButton() {
/** // TODO Auto-generated method stub
* return (UIColorButton) super.getLeftButton();
*/ }
public UIColorButton getLeftButton() {
// TODO Auto-generated method stub @Override
return (UIColorButton) super.getLeftButton(); public Color getColor() {
} return this.color;
}
/**
* @return @Override
*/ public void setColor(Color color) {
public Color getColor() { setColorWithoutchanged(color);
return this.color; fireColorStateChanged();
} }
/** /**
* @param color * 设置颜色
*/ *
public void setColor(Color color) { * @param color 颜色
setColorWithoutchanged(color); */
fireColorStateChanged(); public void setColorWithoutchanged(Color color) {
} this.color = color;
getLeftButton().setColor(color);
/** }
* 设置颜色
* @param color 颜色 /**
*/ * 是否可为NULL值
public void setColorWithoutchanged(Color color) { *
this.color = color; * @return 同上
getLeftButton().setColor(color); */
} public boolean isCanBeNull() {
return this.isCanBeNull;
/** }
* 是否可为NULL值
* @return 同上 /**
*/ * @param isCanBeNull
public boolean isCanBeNull() { */
return this.isCanBeNull; public void setCanBeNull(boolean isCanBeNull) {
} this.isCanBeNull = isCanBeNull;
}
/**
* @param isCanBeNull @Override
*/ public void setEnabled(boolean enabled) {
public void setCanBeNull(boolean isCanBeNull) { super.setEnabled(enabled);
this.isCanBeNull = isCanBeNull;
} if (!enabled) {
color = null;
@Override }
/**
* getLeftButton().setEnabled(enabled);
*/ getLeftButton().setEnabled(enabled);
public void setEnabled(boolean enabled) { }
super.setEnabled(enabled);
@Override
if (!enabled) { public void setToolTipText(String tooltipText) {
color = null; getLeftButton().setToolTipText(tooltipText);
} getLeftButton().setToolTipText(tooltipText);
}
getLeftButton().setEnabled(enabled);
getLeftButton().setEnabled(enabled); private void showPopupMenu() {
} if (popupWin != null && popupWin.isVisible()) {
hidePopupMenu();
@Override return;
/** }
*
*/ if (!this.isEnabled()) {
public void setToolTipText(String tooltipText) { return;
getLeftButton().setToolTipText(tooltipText); }
getLeftButton().setToolTipText(tooltipText);
} popupWin = this.getColorControlWindow();
private void showPopupMenu() { GUICoreUtils.showPopupMenu(popupWin, this, 0, this.getSize().height);
if (popupWin != null && popupWin.isVisible()) { }
hidePopupMenu();
return; /**
} * 隐藏弹出框
*/
if (!this.isEnabled()) { @Override
return; public void hidePopupMenu() {
} if (popupWin != null && !OperatingSystem.isMacos()) {
popupWin.setVisible(false);
popupWin = this.getColorControlWindow(); }
GUICoreUtils.showPopupMenu(popupWin, this, 0, this.getSize().height); popupWin = null;
} }
/** private ColorControlWindow getColorControlWindow() {
* 隐藏弹出框 //find parant.
*/ if (this.popupWin == null) {
public void hidePopupMenu() { this.popupWin = new ColorControlWindow(this.isCanBeNull(), UIToolbarColorButton.this) {
if (popupWin != null) { @Override
popupWin.setVisible(false); protected void colorChanged() {
} UIToolbarColorButton.this.setColor(this.getColor());
}
popupWin = null;
} };
}
private ColorControlWindow getColorControlWindow() {
//find parant. return popupWin;
if (this.popupWin == null) { }
this.popupWin = new ColorControlWindow(this.isCanBeNull(), UIToolbarColorButton.this) {
@Override /**
protected void colorChanged() { * Adds a new ColorChangeListener
UIToolbarColorButton.this.setColor(this.getColor()); * 注册监听
} *
* @param changeListener 监听
}; */
} public void addColorChangeListener(ChangeListener changeListener) {
colorChangeListenerList.add(ChangeListener.class, changeListener);
return popupWin; }
}
/**
/** * Removes an old ColorChangeListener.
* Adds a new ColorChangeListener * 移除监听
* 注册监听 *
* @param changeListener 监听 * @param changeListener 监听
*/ */
public void addColorChangeListener(ChangeListener changeListener) { public void removeColorChangeListener(ChangeListener changeListener) {
colorChangeListenerList.add(ChangeListener.class, changeListener); colorChangeListenerList.remove(ChangeListener.class, changeListener);
} }
/** /**
* Removes an old ColorChangeListener. * 触发颜色改变事件
* 移除监听 */
* @param changeListener 监听 public void fireColorStateChanged() {
*/ Object[] listeners = colorChangeListenerList.getListenerList();
public void removeColorChangeListener(ChangeListener changeListener) { ChangeEvent e = null;
colorChangeListenerList.remove(ChangeListener.class, changeListener);
} for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == ChangeListener.class) {
/** if (e == null) {
* 触发颜色改变事件 e = new ChangeEvent(this);
* }
*/ ((ChangeListener) listeners[i + 1]).stateChanged(e);
public void fireColorStateChanged() { }
Object[] listeners = colorChangeListenerList.getListenerList(); }
ChangeEvent e = null; }
for (int i = listeners.length - 2; i >= 0; i -= 2) { @Override
if (listeners[i] == ChangeListener.class) { protected void leftButtonClickEvent() {
if (e == null) { color = getLeftButton().getColor();
e = new ChangeEvent(this); fireColorStateChanged();
} }
((ChangeListener) listeners[i + 1]).stateChanged(e);
} @Override
} protected void rightButtonClickEvent() {
} showPopupMenu();
}
protected void leftButtonClickEvent() {
color = getLeftButton().getColor(); /**
fireColorStateChanged(); * 选中颜色
} *
* @param colorCell 颜色单元格
@Override */
protected void rightButtonClickEvent() { @Override
showPopupMenu(); public void colorSetted(ColorCell colorCell) {
} hidePopupMenu();
}
@Override
/** /**
* 选中颜色 * 注册监听
* @param colorCell 颜色单元格 *
*/ * @param listener 监听
public void colorSetted(ColorCell colorCell) { */
hidePopupMenu(); @Override
} public void registerChangeListener(UIObserverListener listener) {
uiObserverListener = listener;
@Override }
/**
* 注册监听 /**
* @param listener 监听 * 是否响应监听
*/ *
public void registerChangeListener(UIObserverListener listener) { * @return 同上
uiObserverListener = listener; */
} @Override
public boolean shouldResponseChangeListener() {
@Override return true;
/** }
* 是否响应监听
* @return 同上
*/
public boolean shouldResponseChangeListener() {
return true;
}
} }

2
designer-base/src/main/java/com/fr/start/BaseDesigner.java

@ -26,7 +26,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import java.awt.*; import java.awt.Window;
import java.io.File; import java.io.File;
import java.lang.reflect.Method; import java.lang.reflect.Method;

Loading…
Cancel
Save