pengda
3 years ago
27 changed files with 302 additions and 81 deletions
@ -0,0 +1,50 @@
|
||||
package com.fr.design.mainframe.share.ui.actions; |
||||
|
||||
import com.fr.design.gui.imenu.UIMenuItem; |
||||
import com.fr.design.mainframe.share.ui.constants.ColorConstants; |
||||
import com.fr.general.IOUtils; |
||||
|
||||
import javax.swing.Action; |
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.Icon; |
||||
import java.awt.Graphics; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2021/10/19 |
||||
*/ |
||||
public class LoadingMenuItem extends UIMenuItem { |
||||
private boolean loading = false; |
||||
|
||||
private final Icon profileIcon = IOUtils.readIcon("/com/fr/design/form/images/loading.gif"); |
||||
|
||||
public LoadingMenuItem(Action action) { |
||||
super(action); |
||||
setOpaque(true); |
||||
setBackground(ColorConstants.BACKGROUND); |
||||
setUI(new SharedComponentActionMenuItemUI(false)); |
||||
} |
||||
|
||||
public void startLoading() { |
||||
loading = true; |
||||
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); |
||||
revalidate(); |
||||
repaint(); |
||||
} |
||||
|
||||
public void stopLoading() { |
||||
loading = false; |
||||
setBorder(BorderFactory.createEmptyBorder()); |
||||
revalidate(); |
||||
repaint(); |
||||
} |
||||
|
||||
@Override |
||||
protected void paintBorder(Graphics g) { |
||||
super.paintBorder(g); |
||||
if (loading) { |
||||
profileIcon.paintIcon(this, g, getWidth() - 20, 0); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.fr.design.mainframe.share.ui.actions; |
||||
|
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.gui.imenu.UIMenuItemUI; |
||||
import com.fr.design.utils.gui.GUIPaintUtils; |
||||
import com.fr.stable.Constants; |
||||
|
||||
import javax.swing.ButtonModel; |
||||
import javax.swing.JMenu; |
||||
import javax.swing.JMenuItem; |
||||
import javax.swing.MenuSelectionManager; |
||||
import java.awt.Color; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2021/10/18 |
||||
*/ |
||||
public class SharedComponentActionMenuItemUI extends UIMenuItemUI { |
||||
|
||||
private final boolean autoClosePopup; |
||||
|
||||
public SharedComponentActionMenuItemUI(boolean autoClosePopup) { |
||||
this.autoClosePopup = autoClosePopup; |
||||
} |
||||
|
||||
public SharedComponentActionMenuItemUI() { |
||||
this(true); |
||||
} |
||||
|
||||
@Override |
||||
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { |
||||
ButtonModel model = menuItem.getModel(); |
||||
Color oldColor = g.getColor(); |
||||
int menuWidth = menuItem.getWidth(); |
||||
int menuHeight = menuItem.getHeight(); |
||||
|
||||
if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { |
||||
GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 0); |
||||
} |
||||
|
||||
g.setColor(oldColor); |
||||
} |
||||
|
||||
@Override |
||||
protected void doClick(MenuSelectionManager msm) { |
||||
if (autoClosePopup) { |
||||
super.doClick(msm); |
||||
} else { |
||||
menuItem.doClick(0); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
package com.fr.design.mainframe.share.ui.constants; |
||||
|
||||
import java.awt.Color; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2021/10/19 |
||||
*/ |
||||
public class ColorConstants { |
||||
public static final Color BACKGROUND = new Color(0xF0F0F1); |
||||
} |
After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 10 KiB |
Loading…
Reference in new issue