Browse Source

Merge pull request #1391 in DESIGN/design from ~VITO/c-design:release/10.0 to release/10.0

* commit 'd6b790249cc6a1654ededf498930fe9d33019f91':
  REPORT-25645 mac设计器取色器异常
feature/big-screen
vito 5 years ago
parent
commit
d30dfda067
  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;
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.design.constants.UIConstants;
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.UIObserverListener;
import com.fr.design.gui.ipoppane.PopupHider;
import com.fr.general.ComparatorUtils;
import com.fr.design.style.color.ColorControlWindow;
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 {
private static final int SIZE = 16;
private static final int SIZE_2 = 2;
private static final int SIZE_4 = 4;
private static final int SIZE_6 = 6;
private static final int POPUP_MENU_SHIFT = -70;
private Color color = Color.BLACK;
private ColorControlWindow popupWin;
private EventListenerList colorChangeListenerList = new EventListenerList();
private boolean isEventBanned = false;
private String colorButtonName = "";
private UIObserverListener uiObserverListener;
private GlobalNameListener globalNameListener = null;
public UIColorButton() {
this(UIConstants.FONT_ICON);
}
public UIColorButton(Icon icon) {
super(icon);
setUI(getButtonUI());
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
showPopupMenu();
}
});
iniListener();
}
private void iniListener() {
if (shouldResponseChangeListener()) {
this.addColorChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (uiObserverListener == null) {
return;
}
if (globalNameListener != null && shouldResponseNameListener()) {
globalNameListener.setGlobalName(colorButtonName);
}
uiObserverListener.doChange();
}
});
}
}
private UIButtonUI getButtonUI() {
return new UIButtonUI() {
@Override
protected void paintIcon(Graphics g, JComponent c) {
super.paintIcon(g, c);
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
if (model.isEnabled()) {
g.setColor(UIColorButton.this.getColor());
} else {
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);
}
};
}
public void setEventBanned(boolean isEventBanned) {
this.isEventBanned = isEventBanned;
}
public void setGlobalName(String name) {
colorButtonName = name;
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
if (ComparatorUtils.equals(this.color, color)) {
return;
}
this.color = color;
hidePopupMenu();
fireColorStateChanged();
}
private void showPopupMenu() {
if (isEventBanned) {
return;
}
if (popupWin != null && popupWin.isVisible()) {
hidePopupMenu();
return;
}
if (!this.isEnabled()) {
return;
}
popupWin = this.getColorControlWindow();
GUICoreUtils.showPopupMenu(popupWin, this, POPUP_MENU_SHIFT, this.getSize().height);
}
/**
* 隐藏popupmenu
*/
public void hidePopupMenu() {
if (popupWin != null) {
popupWin.setVisible(false);
repaint();
}
popupWin = null;
}
private ColorControlWindow getColorControlWindow() {
//find parant.
if (this.popupWin == null) {
this.popupWin = new ColorControlWindow(UIColorButton.this) {
@Override
protected void colorChanged() {
UIColorButton.this.setColor(this.getColor());
}
};
}
return popupWin;
}
/**
* 添加监听
*
* @param changeListener 监听列表
*/
public void addColorChangeListener(ChangeListener changeListener) {
colorChangeListenerList.add(ChangeListener.class, changeListener);
}
/**
* 移除监听
* Removes an old ColorChangeListener.
* @param changeListener 监听列表
*/
public void removeColorChangeListener(ChangeListener changeListener) {
colorChangeListenerList.remove(ChangeListener.class, changeListener);
}
/**
* 颜色状态改变
*/
public void fireColorStateChanged() {
Object[] listeners = colorChangeListenerList.getListenerList();
ChangeEvent e = null;
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);
}
}
}
/**
* 注册状态改变监听
*
* @param listener 观察者监听事件
*/
public void registerChangeListener(UIObserverListener listener) {
uiObserverListener = listener;
}
/**
* 是否需要响应监听
*
* @return 是否响应
*/
public boolean shouldResponseChangeListener() {
return true;
}
/**
* 注册监听
*
* @param listener 观察者监听事件
*/
public void registerNameListener(GlobalNameListener listener) {
globalNameListener = listener;
}
/**
* 是否需要相应
*
* @return 是否响应
*/
public boolean shouldResponseNameListener() {
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);
}
private static final int SIZE = 16;
private static final int SIZE_2 = 2;
private static final int SIZE_4 = 4;
private static final int SIZE_6 = 6;
private static final int POPUP_MENU_SHIFT = -70;
private Color color = Color.BLACK;
private ColorControlWindow popupWin;
private EventListenerList colorChangeListenerList = new EventListenerList();
private boolean isEventBanned = false;
private String colorButtonName = "";
private UIObserverListener uiObserverListener;
private GlobalNameListener globalNameListener = null;
public UIColorButton() {
this(UIConstants.FONT_ICON);
}
public UIColorButton(Icon icon) {
super(icon);
setUI(getButtonUI());
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
showPopupMenu();
}
});
iniListener();
}
private void iniListener() {
if (shouldResponseChangeListener()) {
this.addColorChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (uiObserverListener == null) {
return;
}
if (globalNameListener != null && shouldResponseNameListener()) {
globalNameListener.setGlobalName(colorButtonName);
}
uiObserverListener.doChange();
}
});
}
}
private UIButtonUI getButtonUI() {
return new UIButtonUI() {
@Override
protected void paintIcon(Graphics g, JComponent c) {
super.paintIcon(g, c);
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
if (model.isEnabled()) {
g.setColor(UIColorButton.this.getColor());
} else {
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);
}
};
}
public void setEventBanned(boolean isEventBanned) {
this.isEventBanned = isEventBanned;
}
public void setGlobalName(String name) {
colorButtonName = name;
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
if (ComparatorUtils.equals(this.color, color)) {
return;
}
this.color = color;
hidePopupMenu();
fireColorStateChanged();
}
private void showPopupMenu() {
if (isEventBanned) {
return;
}
if (popupWin != null && popupWin.isVisible()) {
hidePopupMenu();
return;
}
if (!this.isEnabled()) {
return;
}
popupWin = this.getColorControlWindow();
GUICoreUtils.showPopupMenu(popupWin, this, POPUP_MENU_SHIFT, this.getSize().height);
}
/**
* 隐藏popupmenu
*/
public void hidePopupMenu() {
if (popupWin != null) {
popupWin.setVisible(false);
}
popupWin = null;
repaint();
}
private ColorControlWindow getColorControlWindow() {
//find parant.
if (this.popupWin == null) {
this.popupWin = new ColorControlWindow(UIColorButton.this) {
@Override
protected void colorChanged() {
UIColorButton.this.setColor(this.getColor());
}
};
}
return popupWin;
}
/**
* 添加监听
*
* @param changeListener 监听列表
*/
public void addColorChangeListener(ChangeListener changeListener) {
colorChangeListenerList.add(ChangeListener.class, changeListener);
}
/**
* 移除监听
* Removes an old ColorChangeListener.
*
* @param changeListener 监听列表
*/
public void removeColorChangeListener(ChangeListener changeListener) {
colorChangeListenerList.remove(ChangeListener.class, changeListener);
}
/**
* 颜色状态改变
*/
public void fireColorStateChanged() {
Object[] listeners = colorChangeListenerList.getListenerList();
ChangeEvent e = null;
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);
}
}
}
/**
* 注册状态改变监听
*
* @param listener 观察者监听事件
*/
public void registerChangeListener(UIObserverListener listener) {
uiObserverListener = listener;
}
/**
* 是否需要响应监听
*
* @return 是否响应
*/
public boolean shouldResponseChangeListener() {
return true;
}
/**
* 注册监听
*
* @param listener 观察者监听事件
*/
public void registerNameListener(GlobalNameListener listener) {
globalNameListener = listener;
}
/**
* 是否需要相应
*
* @return 是否响应
*/
public boolean shouldResponseNameListener() {
return true;
}
}

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

@ -1,40 +1,41 @@
package com.fr.design.style.color;
import java.awt.BorderLayout;
import java.awt.Color;
import com.fr.design.gui.ipoppane.PopupHider;
import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.JPopupMenu;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.design.gui.ipoppane.PopupHider;
import com.fr.design.layout.FRGUIPaneFactory;
import java.awt.BorderLayout;
import java.awt.Color;
public abstract class ColorControlWindow extends JPopupMenu {
private static final long serialVersionUID = 4317136753151221742L;
private PopupHider popupHider;
private ColorSelectionPopupPane selectionPopupPane;
protected abstract void colorChanged();
private static final long serialVersionUID = 4317136753151221742L;
private PopupHider popupHider;
private ColorSelectionPopupPane selectionPopupPane;
/**
protected abstract void colorChanged();
/**
* Constructor.
*/
public ColorControlWindow(PopupHider popupHider) {
this(false,popupHider);
this(false, popupHider);
}
/**
/**
* Constructor.
*/
public ColorControlWindow(boolean isSupportTransparent, PopupHider popupHider) {
this.initComponents(isSupportTransparent);
this.popupHider = popupHider;
}
public Color getColor() {
if(selectionPopupPane == null) {
return null;
}
return selectionPopupPane.getColor();
if (selectionPopupPane == null) {
return null;
}
return selectionPopupPane.getColor();
}
/**
@ -52,30 +53,33 @@ public abstract class ColorControlWindow extends JPopupMenu {
this.add(selectionPopupPane, BorderLayout.CENTER);
this.pack();
}
class ColorSelectionPopupPane extends NewColorSelectPane {
private static final long serialVersionUID = 7822856562329146354L;
public ColorSelectionPopupPane(boolean isSupportTransparent) {
super(isSupportTransparent);
this.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
colorChanged();
}
});
private static final long serialVersionUID = 7822856562329146354L;
public ColorSelectionPopupPane(boolean isSupportTransparent) {
super(isSupportTransparent);
this.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
colorChanged();
}
});
}
@Override
protected void doTransparent() {
popupHider.hidePopupMenu();
super.doTransparent();
}
@Override
public void customButtonPressed() {
popupHider.hidePopupMenu();
super.customButtonPressed();
}
popupHider.hidePopupMenu();
super.doTransparent();
}
@Override
public void 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 java.awt.*;
import static com.fr.design.i18n.Toolkit.i18nText;
/**
* 颜色选择器更多颜色面板
*
@ -56,7 +58,7 @@ public class ColorSelectDetailPane extends BasicPane {
@Override
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() {
@ -65,20 +67,15 @@ public class ColorSelectDetailPane extends BasicPane {
// 颜色选择器面板
selectedPanel = new JColorChooser(this.color);
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());
AbstractColorChooserPanel swatchChooserPanel = new SwatchChooserPanel();
AbstractColorChooserPanel customChooserPanel = new CustomChooserPanel();
selectedPanel.addChooserPanel(swatchChooserPanel);
selectedPanel.addChooserPanel(customChooserPanel);
selectedPanel.setChooserPanels(new AbstractColorChooserPanel[]{swatchChooserPanel, customChooserPanel});
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);
recentUsePanel.add(recent);
@ -87,7 +84,7 @@ public class ColorSelectDetailPane extends BasicPane {
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();
ColorSelectionModel model = selectedPanel.getSelectionModel();
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;
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.design.event.UIObserver;
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.ipoppane.PopupHider;
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.
*/
public class UIToolbarColorButton extends UICombinationButton implements PopupHider, ColorSelectable, UIObserver {
private static final long serialVersionUID = 3220957076370197935L;
private Color color = null;
private boolean isCanBeNull = false;
private ColorControlWindow popupWin;
//color setting action.
private EventListenerList colorChangeListenerList = new EventListenerList();
private UIObserverListener uiObserverListener;
public UIToolbarColorButton(Icon icon) {
super(new UIColorButton(icon), new UIButton(BaseUtils.readIcon("/com/fr/design/images/gui/popup.gif")));
getLeftButton().setEventBanned(true);
getRightButton().addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent e) {
hidePopupMenu();
}
});
iniListener();
}
private void iniListener() {
if (shouldResponseChangeListener()) {
this.addColorChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (uiObserverListener == null) {
return;
}
uiObserverListener.doChange();
}
});
}
}
@Override
/**
*
*/
public UIColorButton getLeftButton() {
// TODO Auto-generated method stub
return (UIColorButton) super.getLeftButton();
}
/**
* @return
*/
public Color getColor() {
return this.color;
}
/**
* @param color
*/
public void setColor(Color color) {
setColorWithoutchanged(color);
fireColorStateChanged();
}
/**
* 设置颜色
* @param color 颜色
*/
public void setColorWithoutchanged(Color color) {
this.color = color;
getLeftButton().setColor(color);
}
/**
* 是否可为NULL值
* @return 同上
*/
public boolean isCanBeNull() {
return this.isCanBeNull;
}
/**
* @param isCanBeNull
*/
public void setCanBeNull(boolean isCanBeNull) {
this.isCanBeNull = isCanBeNull;
}
@Override
/**
*
*/
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
if (!enabled) {
color = null;
}
getLeftButton().setEnabled(enabled);
getLeftButton().setEnabled(enabled);
}
@Override
/**
*
*/
public void setToolTipText(String tooltipText) {
getLeftButton().setToolTipText(tooltipText);
getLeftButton().setToolTipText(tooltipText);
}
private void showPopupMenu() {
if (popupWin != null && popupWin.isVisible()) {
hidePopupMenu();
return;
}
if (!this.isEnabled()) {
return;
}
popupWin = this.getColorControlWindow();
GUICoreUtils.showPopupMenu(popupWin, this, 0, this.getSize().height);
}
/**
* 隐藏弹出框
*/
public void hidePopupMenu() {
if (popupWin != null) {
popupWin.setVisible(false);
}
popupWin = null;
}
private ColorControlWindow getColorControlWindow() {
//find parant.
if (this.popupWin == null) {
this.popupWin = new ColorControlWindow(this.isCanBeNull(), UIToolbarColorButton.this) {
@Override
protected void colorChanged() {
UIToolbarColorButton.this.setColor(this.getColor());
}
};
}
return popupWin;
}
/**
* Adds a new ColorChangeListener
* 注册监听
* @param changeListener 监听
*/
public void addColorChangeListener(ChangeListener changeListener) {
colorChangeListenerList.add(ChangeListener.class, changeListener);
}
/**
* Removes an old ColorChangeListener.
* 移除监听
* @param changeListener 监听
*/
public void removeColorChangeListener(ChangeListener changeListener) {
colorChangeListenerList.remove(ChangeListener.class, changeListener);
}
/**
* 触发颜色改变事件
*
*/
public void fireColorStateChanged() {
Object[] listeners = colorChangeListenerList.getListenerList();
ChangeEvent e = null;
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);
}
}
}
protected void leftButtonClickEvent() {
color = getLeftButton().getColor();
fireColorStateChanged();
}
@Override
protected void rightButtonClickEvent() {
showPopupMenu();
}
@Override
/**
* 选中颜色
* @param colorCell 颜色单元格
*/
public void colorSetted(ColorCell colorCell) {
hidePopupMenu();
}
@Override
/**
* 注册监听
* @param listener 监听
*/
public void registerChangeListener(UIObserverListener listener) {
uiObserverListener = listener;
}
@Override
/**
* 是否响应监听
* @return 同上
*/
public boolean shouldResponseChangeListener() {
return true;
}
private static final long serialVersionUID = 3220957076370197935L;
private Color color = null;
private boolean isCanBeNull = false;
private ColorControlWindow popupWin;
//color setting action.
private EventListenerList colorChangeListenerList = new EventListenerList();
private UIObserverListener uiObserverListener;
public UIToolbarColorButton(Icon icon) {
super(new UIColorButton(icon), new UIButton(BaseUtils.readIcon("/com/fr/design/images/gui/popup.gif")));
getLeftButton().setEventBanned(true);
getRightButton().addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent e) {
hidePopupMenu();
}
});
iniListener();
}
private void iniListener() {
if (shouldResponseChangeListener()) {
this.addColorChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (uiObserverListener == null) {
return;
}
uiObserverListener.doChange();
}
});
}
}
@Override
public UIColorButton getLeftButton() {
// TODO Auto-generated method stub
return (UIColorButton) super.getLeftButton();
}
@Override
public Color getColor() {
return this.color;
}
@Override
public void setColor(Color color) {
setColorWithoutchanged(color);
fireColorStateChanged();
}
/**
* 设置颜色
*
* @param color 颜色
*/
public void setColorWithoutchanged(Color color) {
this.color = color;
getLeftButton().setColor(color);
}
/**
* 是否可为NULL值
*
* @return 同上
*/
public boolean isCanBeNull() {
return this.isCanBeNull;
}
/**
* @param isCanBeNull
*/
public void setCanBeNull(boolean isCanBeNull) {
this.isCanBeNull = isCanBeNull;
}
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
if (!enabled) {
color = null;
}
getLeftButton().setEnabled(enabled);
getLeftButton().setEnabled(enabled);
}
@Override
public void setToolTipText(String tooltipText) {
getLeftButton().setToolTipText(tooltipText);
getLeftButton().setToolTipText(tooltipText);
}
private void showPopupMenu() {
if (popupWin != null && popupWin.isVisible()) {
hidePopupMenu();
return;
}
if (!this.isEnabled()) {
return;
}
popupWin = this.getColorControlWindow();
GUICoreUtils.showPopupMenu(popupWin, this, 0, this.getSize().height);
}
/**
* 隐藏弹出框
*/
@Override
public void hidePopupMenu() {
if (popupWin != null && !OperatingSystem.isMacos()) {
popupWin.setVisible(false);
}
popupWin = null;
}
private ColorControlWindow getColorControlWindow() {
//find parant.
if (this.popupWin == null) {
this.popupWin = new ColorControlWindow(this.isCanBeNull(), UIToolbarColorButton.this) {
@Override
protected void colorChanged() {
UIToolbarColorButton.this.setColor(this.getColor());
}
};
}
return popupWin;
}
/**
* Adds a new ColorChangeListener
* 注册监听
*
* @param changeListener 监听
*/
public void addColorChangeListener(ChangeListener changeListener) {
colorChangeListenerList.add(ChangeListener.class, changeListener);
}
/**
* Removes an old ColorChangeListener.
* 移除监听
*
* @param changeListener 监听
*/
public void removeColorChangeListener(ChangeListener changeListener) {
colorChangeListenerList.remove(ChangeListener.class, changeListener);
}
/**
* 触发颜色改变事件
*/
public void fireColorStateChanged() {
Object[] listeners = colorChangeListenerList.getListenerList();
ChangeEvent e = null;
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);
}
}
}
@Override
protected void leftButtonClickEvent() {
color = getLeftButton().getColor();
fireColorStateChanged();
}
@Override
protected void rightButtonClickEvent() {
showPopupMenu();
}
/**
* 选中颜色
*
* @param colorCell 颜色单元格
*/
@Override
public void colorSetted(ColorCell colorCell) {
hidePopupMenu();
}
/**
* 注册监听
*
* @param listener 监听
*/
@Override
public void registerChangeListener(UIObserverListener listener) {
uiObserverListener = listener;
}
/**
* 是否响应监听
*
* @return 同上
*/
@Override
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.stable.OperatingSystem;
import java.awt.*;
import java.awt.Window;
import java.io.File;
import java.lang.reflect.Method;

Loading…
Cancel
Save