Browse Source

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

feature/big-screen
vito 5 years ago
parent
commit
d6b790249c
  1. 52
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java
  2. 18
      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. 54
      designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java
  5. 2
      designer-base/src/main/java/com/fr/start/BaseDesigner.java

52
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,9 +7,21 @@ 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;
@ -136,10 +134,9 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G
public void hidePopupMenu() { public void hidePopupMenu() {
if (popupWin != null) { if (popupWin != null) {
popupWin.setVisible(false); popupWin.setVisible(false);
repaint();
} }
popupWin = null; popupWin = null;
repaint();
} }
private ColorControlWindow getColorControlWindow() { private ColorControlWindow getColorControlWindow() {
@ -169,6 +166,7 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G
/** /**
* 移除监听 * 移除监听
* Removes an old ColorChangeListener. * Removes an old ColorChangeListener.
*
* @param changeListener 监听列表 * @param changeListener 监听列表
*/ */
public void removeColorChangeListener(ChangeListener changeListener) { public void removeColorChangeListener(ChangeListener changeListener) {
@ -228,24 +226,4 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G
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);
}
} }

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

@ -1,27 +1,28 @@
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.
*/ */
@ -31,7 +32,7 @@ public abstract class ColorControlWindow extends JPopupMenu {
} }
public Color getColor() { public Color getColor() {
if(selectionPopupPane == null) { if (selectionPopupPane == null) {
return null; return null;
} }
return selectionPopupPane.getColor(); return selectionPopupPane.getColor();
@ -55,6 +56,7 @@ public abstract class ColorControlWindow extends JPopupMenu {
class ColorSelectionPopupPane extends NewColorSelectPane { class ColorSelectionPopupPane extends NewColorSelectPane {
private static final long serialVersionUID = 7822856562329146354L; private static final long serialVersionUID = 7822856562329146354L;
public ColorSelectionPopupPane(boolean isSupportTransparent) { public ColorSelectionPopupPane(boolean isSupportTransparent) {
super(isSupportTransparent); super(isSupportTransparent);
this.addChangeListener(new ChangeListener() { this.addChangeListener(new ChangeListener() {
@ -65,11 +67,13 @@ public abstract class ColorControlWindow extends JPopupMenu {
} }
}); });
} }
@Override @Override
protected void doTransparent() { protected void doTransparent() {
popupHider.hidePopupMenu(); popupHider.hidePopupMenu();
super.doTransparent(); super.doTransparent();
} }
@Override @Override
public void customButtonPressed() { public void customButtonPressed() {
popupHider.hidePopupMenu(); popupHider.hidePopupMenu();

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() {

54
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,6 +11,15 @@ 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.
@ -33,7 +33,6 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi
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);
@ -66,24 +65,17 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi
} }
@Override @Override
/**
*
*/
public UIColorButton getLeftButton() { public UIColorButton getLeftButton() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return (UIColorButton) super.getLeftButton(); return (UIColorButton) super.getLeftButton();
} }
/** @Override
* @return
*/
public Color getColor() { public Color getColor() {
return this.color; return this.color;
} }
/** @Override
* @param color
*/
public void setColor(Color color) { public void setColor(Color color) {
setColorWithoutchanged(color); setColorWithoutchanged(color);
fireColorStateChanged(); fireColorStateChanged();
@ -91,6 +83,7 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi
/** /**
* 设置颜色 * 设置颜色
*
* @param color 颜色 * @param color 颜色
*/ */
public void setColorWithoutchanged(Color color) { public void setColorWithoutchanged(Color color) {
@ -100,6 +93,7 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi
/** /**
* 是否可为NULL值 * 是否可为NULL值
*
* @return 同上 * @return 同上
*/ */
public boolean isCanBeNull() { public boolean isCanBeNull() {
@ -114,9 +108,6 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi
} }
@Override @Override
/**
*
*/
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
super.setEnabled(enabled); super.setEnabled(enabled);
@ -129,9 +120,6 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi
} }
@Override @Override
/**
*
*/
public void setToolTipText(String tooltipText) { public void setToolTipText(String tooltipText) {
getLeftButton().setToolTipText(tooltipText); getLeftButton().setToolTipText(tooltipText);
getLeftButton().setToolTipText(tooltipText); getLeftButton().setToolTipText(tooltipText);
@ -155,8 +143,9 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi
/** /**
* 隐藏弹出框 * 隐藏弹出框
*/ */
@Override
public void hidePopupMenu() { public void hidePopupMenu() {
if (popupWin != null) { if (popupWin != null && !OperatingSystem.isMacos()) {
popupWin.setVisible(false); popupWin.setVisible(false);
} }
@ -181,6 +170,7 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi
/** /**
* Adds a new ColorChangeListener * Adds a new ColorChangeListener
* 注册监听 * 注册监听
*
* @param changeListener 监听 * @param changeListener 监听
*/ */
public void addColorChangeListener(ChangeListener changeListener) { public void addColorChangeListener(ChangeListener changeListener) {
@ -190,6 +180,7 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi
/** /**
* Removes an old ColorChangeListener. * Removes an old ColorChangeListener.
* 移除监听 * 移除监听
*
* @param changeListener 监听 * @param changeListener 监听
*/ */
public void removeColorChangeListener(ChangeListener changeListener) { public void removeColorChangeListener(ChangeListener changeListener) {
@ -198,7 +189,6 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi
/** /**
* 触发颜色改变事件 * 触发颜色改变事件
*
*/ */
public void fireColorStateChanged() { public void fireColorStateChanged() {
Object[] listeners = colorChangeListenerList.getListenerList(); Object[] listeners = colorChangeListenerList.getListenerList();
@ -214,6 +204,7 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi
} }
} }
@Override
protected void leftButtonClickEvent() { protected void leftButtonClickEvent() {
color = getLeftButton().getColor(); color = getLeftButton().getColor();
fireColorStateChanged(); fireColorStateChanged();
@ -224,29 +215,32 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi
showPopupMenu(); showPopupMenu();
} }
@Override
/** /**
* 选中颜色 * 选中颜色
*
* @param colorCell 颜色单元格 * @param colorCell 颜色单元格
*/ */
@Override
public void colorSetted(ColorCell colorCell) { public void colorSetted(ColorCell colorCell) {
hidePopupMenu(); hidePopupMenu();
} }
@Override
/** /**
* 注册监听 * 注册监听
*
* @param listener 监听 * @param listener 监听
*/ */
@Override
public void registerChangeListener(UIObserverListener listener) { public void registerChangeListener(UIObserverListener listener) {
uiObserverListener = listener; uiObserverListener = listener;
} }
@Override
/** /**
* 是否响应监听 * 是否响应监听
*
* @return 同上 * @return 同上
*/ */
@Override
public boolean shouldResponseChangeListener() { public boolean shouldResponseChangeListener() {
return true; 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