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

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

@ -1,19 +1,19 @@
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();
/**
@ -22,6 +22,7 @@ public abstract class ColorControlWindow extends JPopupMenu {
public ColorControlWindow(PopupHider popupHider) {
this(false, popupHider);
}
/**
* Constructor.
*/
@ -55,6 +56,7 @@ public abstract class ColorControlWindow extends JPopupMenu {
class ColorSelectionPopupPane extends NewColorSelectPane {
private static final long serialVersionUID = 7822856562329146354L;
public ColorSelectionPopupPane(boolean isSupportTransparent) {
super(isSupportTransparent);
this.addChangeListener(new ChangeListener() {
@ -65,11 +67,13 @@ public abstract class ColorControlWindow extends JPopupMenu {
}
});
}
@Override
protected void doTransparent() {
popupHider.hidePopupMenu();
super.doTransparent();
}
@Override
public void customButtonPressed() {
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 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() {

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