Browse Source
# Conflicts: # designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java # designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.javafinal/10.0
jeo
5 years ago
372 changed files with 11586 additions and 2830 deletions
@ -0,0 +1,59 @@ |
|||||||
|
package com.fr.common.detect; |
||||||
|
|
||||||
|
import com.fr.concurrent.NamedThreadFactory; |
||||||
|
import com.fr.design.DesignerEnvManager; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.module.ModuleContext; |
||||||
|
import com.fr.web.WebSocketConfig; |
||||||
|
|
||||||
|
import java.net.Socket; |
||||||
|
import java.util.concurrent.ExecutorService; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/3/10 |
||||||
|
*/ |
||||||
|
public class CommonPortDetector { |
||||||
|
|
||||||
|
private static final CommonPortDetector INSTANCE = new CommonPortDetector(); |
||||||
|
private ExecutorService service = ModuleContext.getExecutor().newSingleThreadExecutor(new NamedThreadFactory("CommonPortDetector")); |
||||||
|
|
||||||
|
public static CommonPortDetector getInstance() { |
||||||
|
return INSTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
public void execute() { |
||||||
|
service.submit(new Runnable() { |
||||||
|
@Override |
||||||
|
public void run() { |
||||||
|
detectTomcatPort(); |
||||||
|
detectWebSocketPort(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private void detectTomcatPort() { |
||||||
|
int port = DesignerEnvManager.getEnvManager().getEmbedServerPort(); |
||||||
|
if (checkPort(port)) { |
||||||
|
FineLoggerFactory.getLogger().error("EmbedTomcat Port: {} is not available, maybe occupied by other programs, please check it!", port); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void detectWebSocketPort() { |
||||||
|
Integer[] ports = WebSocketConfig.getInstance().getPort(); |
||||||
|
for (int port : ports) { |
||||||
|
if (checkPort(port)) { |
||||||
|
FineLoggerFactory.getLogger().error("WebSocKet Port: {} is not available, maybe occupied by other programs, please check it!", port); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private boolean checkPort(int port) { |
||||||
|
try (Socket socket = new Socket("localhost", port)) { |
||||||
|
return true; |
||||||
|
} catch (Exception e) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
package com.fr.common.report; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/3/27 |
||||||
|
*/ |
||||||
|
public enum ReportState { |
||||||
|
|
||||||
|
STOP("stop"), ACTIVE("active"); |
||||||
|
|
||||||
|
private String value; |
||||||
|
|
||||||
|
ReportState(String value) { |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
|
||||||
|
public String getValue() { |
||||||
|
return this.value; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,94 @@ |
|||||||
|
package com.fr.design.dialog; |
||||||
|
|
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
|
||||||
|
import javax.swing.JDialog; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.JTextArea; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.FlowLayout; |
||||||
|
import java.awt.Font; |
||||||
|
import java.awt.Frame; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/1/8 |
||||||
|
*/ |
||||||
|
public abstract class ErrorDialog extends JDialog implements ActionListener { |
||||||
|
|
||||||
|
private UIButton okButton; |
||||||
|
private UIButton restartButton; |
||||||
|
|
||||||
|
|
||||||
|
public ErrorDialog(Frame parent, String message, String title, String detail) { |
||||||
|
super(parent, true); |
||||||
|
JPanel northPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
JPanel messagePane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); |
||||||
|
UILabel boldFontLabel = new UILabel(message); |
||||||
|
UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Send_Report_To_Us")); |
||||||
|
Font font = FRFont.getInstance("Dialog", Font.BOLD, 20); |
||||||
|
boldFontLabel.setFont(font); |
||||||
|
messagePane.add(boldFontLabel); |
||||||
|
messagePane.add(label); |
||||||
|
northPane.add(messagePane); |
||||||
|
|
||||||
|
JTextArea area = new JTextArea(detail); |
||||||
|
area.setPreferredSize(new Dimension(400, 100)); |
||||||
|
area.setEnabled(true); |
||||||
|
area.setEditable(false); |
||||||
|
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
UILabel detailLabel = new UILabel(Toolkit.i18nText("Fine-Design_Problem_Detail_Message")); |
||||||
|
centerPane.add(detailLabel, BorderLayout.NORTH); |
||||||
|
centerPane.add(area, BorderLayout.CENTER); |
||||||
|
|
||||||
|
JPanel southPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
JPanel controlPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
JPanel buttonPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 0)); |
||||||
|
okButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Ok")); |
||||||
|
okButton.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
okEvent(); |
||||||
|
} |
||||||
|
}); |
||||||
|
buttonPane.add(okButton); |
||||||
|
restartButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Restart")); |
||||||
|
restartButton.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
restartEvent(); |
||||||
|
} |
||||||
|
}); |
||||||
|
buttonPane.add(restartButton); |
||||||
|
controlPane.add(buttonPane, BorderLayout.EAST); |
||||||
|
southPane.add(controlPane); |
||||||
|
|
||||||
|
this.setTitle(title); |
||||||
|
this.setResizable(false); |
||||||
|
this.add(northPane, BorderLayout.NORTH); |
||||||
|
this.add(centerPane, BorderLayout.CENTER); |
||||||
|
this.add(southPane, BorderLayout.SOUTH); |
||||||
|
this.setSize(new Dimension(600, 500)); |
||||||
|
GUICoreUtils.centerWindow(this); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
dispose(); |
||||||
|
} |
||||||
|
|
||||||
|
protected abstract void okEvent(); |
||||||
|
|
||||||
|
protected abstract void restartEvent(); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,98 @@ |
|||||||
|
package com.fr.design.dialog; |
||||||
|
|
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.FlowLayout; |
||||||
|
import java.awt.Frame; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/1/8 |
||||||
|
*/ |
||||||
|
public abstract class TipDialog extends JDialog implements ActionListener { |
||||||
|
|
||||||
|
private UIButton endButton; |
||||||
|
private UIButton cancelButton; |
||||||
|
|
||||||
|
public TipDialog(Frame parent, String type, String tip, String endText, String cancelText) { |
||||||
|
super(parent, true); |
||||||
|
JPanel northPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
JPanel iconPane = new JPanel(); |
||||||
|
UILabel iconLabel = new UILabel(); |
||||||
|
iconLabel.setIcon(IOUtils.readIcon("com/fr/design/images/error/error2.png")); |
||||||
|
iconPane.add(iconLabel); |
||||||
|
iconPane.setPreferredSize(new Dimension(50, 50)); |
||||||
|
JPanel tipPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
UILabel tipLabel = new UILabel(tip); |
||||||
|
tipPane.add(tipLabel); |
||||||
|
northPane.add(iconPane, BorderLayout.WEST); |
||||||
|
northPane.add(tipPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
JTextPane area = new JTextPane(); |
||||||
|
UILabel typeLabel = new UILabel(type); |
||||||
|
area.insertComponent(typeLabel); |
||||||
|
if (StringUtils.isNotEmpty(type)) { |
||||||
|
UILabel logoIconLabel = new UILabel(); |
||||||
|
logoIconLabel.setIcon(IOUtils.readIcon("com/fr/base/images/oem/logo.png")); |
||||||
|
area.insertComponent(logoIconLabel); |
||||||
|
} |
||||||
|
area.setPreferredSize(new Dimension(400, 100)); |
||||||
|
area.setEnabled(true); |
||||||
|
area.setEditable(false); |
||||||
|
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
centerPane.add(area); |
||||||
|
|
||||||
|
JPanel southPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
JPanel controlPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
JPanel buttonPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 0)); |
||||||
|
endButton = new UIButton(endText); |
||||||
|
endButton.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
endEvent(); |
||||||
|
} |
||||||
|
}); |
||||||
|
buttonPane.add(endButton); |
||||||
|
cancelButton = new UIButton(cancelText); |
||||||
|
cancelButton.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
cancelEvent(); |
||||||
|
} |
||||||
|
}); |
||||||
|
buttonPane.add(cancelButton); |
||||||
|
controlPane.add(buttonPane, BorderLayout.EAST); |
||||||
|
southPane.add(controlPane); |
||||||
|
|
||||||
|
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Error_Tittle")); |
||||||
|
this.setResizable(false); |
||||||
|
this.add(northPane, BorderLayout.NORTH); |
||||||
|
this.add(centerPane, BorderLayout.CENTER); |
||||||
|
this.add(southPane, BorderLayout.SOUTH); |
||||||
|
this.setSize(new Dimension(600, 500)); |
||||||
|
GUICoreUtils.centerWindow(this); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
protected abstract void endEvent(); |
||||||
|
|
||||||
|
protected abstract void cancelEvent(); |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
dispose(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
package com.fr.design.fun; |
||||||
|
|
||||||
|
import com.fr.common.annotations.Open; |
||||||
|
import com.fr.stable.fun.mark.Mutable; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2019-11-11 |
||||||
|
*/ |
||||||
|
@Open |
||||||
|
public interface MultiStyleUIConfigProvider extends Mutable { |
||||||
|
String XML_TAG = "MultiStyleUIConfigProvider"; |
||||||
|
|
||||||
|
int CURRENT_LEVEL = 1; |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取配置项list |
||||||
|
* |
||||||
|
* @return 配置项list |
||||||
|
*/ |
||||||
|
List<StyleUIConfigProvider> getConfigList(); |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
package com.fr.design.fun; |
||||||
|
|
||||||
|
import com.fr.base.Style; |
||||||
|
import com.fr.common.annotations.Open; |
||||||
|
import com.fr.stable.fun.mark.Mutable; |
||||||
|
|
||||||
|
import javax.swing.JComponent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2019-11-11 |
||||||
|
*/ |
||||||
|
@Open |
||||||
|
public interface StyleUIConfigProvider extends Mutable { |
||||||
|
String XML_TAG = "CustomStyleUIConfigProvider"; |
||||||
|
|
||||||
|
int CURRENT_LEVEL = 1; |
||||||
|
|
||||||
|
/** |
||||||
|
* @return 配置名 |
||||||
|
*/ |
||||||
|
String configName(); |
||||||
|
|
||||||
|
/** |
||||||
|
* @param changeListener 需要添加的listener |
||||||
|
* @return 对应的component |
||||||
|
*/ |
||||||
|
JComponent uiComponent(ChangeListener changeListener); |
||||||
|
|
||||||
|
/** |
||||||
|
* @return 更新后的样式 |
||||||
|
*/ |
||||||
|
Style updateConfig(); |
||||||
|
|
||||||
|
/** |
||||||
|
* @param style 待渲染的样式 |
||||||
|
*/ |
||||||
|
void populateConfig(Style style); |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
package com.fr.design.fun.impl; |
||||||
|
|
||||||
|
import com.fr.design.fun.StyleUIConfigProvider; |
||||||
|
import com.fr.design.fun.MultiStyleUIConfigProvider; |
||||||
|
import com.fr.stable.fun.impl.AbstractProvider; |
||||||
|
import com.fr.stable.fun.mark.API; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2019-11-11 |
||||||
|
*/ |
||||||
|
@API(level = MultiStyleUIConfigProvider.CURRENT_LEVEL) |
||||||
|
public abstract class AbstractMultiStyleUIConfigProvider extends AbstractProvider implements MultiStyleUIConfigProvider { |
||||||
|
@Override |
||||||
|
public List<StyleUIConfigProvider> getConfigList() { |
||||||
|
return new ArrayList<StyleUIConfigProvider>(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,41 @@ |
|||||||
|
package com.fr.design.fun.impl; |
||||||
|
|
||||||
|
import com.fr.base.Style; |
||||||
|
import com.fr.design.fun.StyleUIConfigProvider; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.stable.fun.impl.AbstractProvider; |
||||||
|
import com.fr.stable.fun.mark.API; |
||||||
|
|
||||||
|
import javax.swing.JComponent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2019-11-11 |
||||||
|
*/ |
||||||
|
@API(level = StyleUIConfigProvider.CURRENT_LEVEL) |
||||||
|
public class AbstractStyleUIConfigProvider extends AbstractProvider implements StyleUIConfigProvider { |
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String configName() { |
||||||
|
return StringUtils.EMPTY; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JComponent uiComponent(ChangeListener changeListener) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Style updateConfig() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateConfig(Style style) { |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
package com.fr.design.gui.ibutton; |
||||||
|
|
||||||
|
import com.fr.chart.base.ChartConstants; |
||||||
|
import com.fr.design.constants.UIConstants; |
||||||
|
import com.fr.design.style.color.ColorControlWindow; |
||||||
|
import com.fr.design.style.color.ColorControlWindowWithAuto; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
|
||||||
|
import java.awt.Color; |
||||||
|
|
||||||
|
public class UIColorButtonWithAuto extends UIColorButton { |
||||||
|
|
||||||
|
protected void checkColorChange(Color oldColor, Color newColor) { |
||||||
|
if (ComparatorUtils.equals(oldColor, ChartConstants.AUTO_FONT_COLOR) && !ComparatorUtils.equals(newColor, ChartConstants.AUTO_FONT_COLOR)) { |
||||||
|
setIcon(UIConstants.FONT_ICON); |
||||||
|
} |
||||||
|
|
||||||
|
if (!ComparatorUtils.equals(oldColor, ChartConstants.AUTO_FONT_COLOR) && ComparatorUtils.equals(newColor, ChartConstants.AUTO_FONT_COLOR)) { |
||||||
|
setIcon(UIConstants.AUTO_FONT_ICON); |
||||||
|
} |
||||||
|
|
||||||
|
super.checkColorChange(oldColor, newColor); |
||||||
|
} |
||||||
|
|
||||||
|
protected ColorControlWindow getColorControlWindow() { |
||||||
|
if (getPopupWin() == null) { |
||||||
|
ColorControlWindowWithAuto colorControlWindowWithAuto = new ColorControlWindowWithAuto(UIColorButtonWithAuto.this) { |
||||||
|
protected void colorChanged() { |
||||||
|
UIColorButtonWithAuto.this.setColor(this.getColor()); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
setPopupWin(colorControlWindowWithAuto); |
||||||
|
} |
||||||
|
|
||||||
|
return getPopupWin(); |
||||||
|
} |
||||||
|
} |
@ -1 +1 @@ |
|||||||
package com.fr.design.gui.ibutton;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import javax.swing.*;
/**
* Author : Shockway
* Date: 13-10-21
* Time: 下午3:23
*/
public class UIPasswordField extends JPasswordField implements UIObserver {
public void registerChangeListener(UIObserverListener listener) {
}
public boolean shouldResponseChangeListener() {
return false;
}
} |
package com.fr.design.gui.ibutton;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import javax.swing.*;
/**
* Author : Shockway
* Date: 13-10-21
* Time: 下午3:23
*/
public class UIPasswordField extends JPasswordField implements UIObserver {
public void registerChangeListener(UIObserverListener listener) {
// do nothing
}
public boolean shouldResponseChangeListener() {
return false;
}
} |
@ -1 +1 @@ |
|||||||
package com.fr.design.gui.ibutton;
import com.fr.design.constants.UIConstants;
import com.fr.stable.Constants;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* Author : daisy
* Date: 13-8-1
* Time: 下午3:41
*/
public class UIPreviewButton extends JPanel {
private static final int START_X = -7;
protected UIButton upButton;
protected UIButton downButton;
protected void upButtonClickEvent() {
}
protected void downButtonClickEvent() {
}
public UIPreviewButton() {
this(new UIButton(), new UIButton());
}
public UIPreviewButton(UIButton up, UIButton down) {
upButton = up;
downButton = down;
upButton.setRoundBorder(true, Constants.CENTER);
downButton.setRoundBorder(true, Constants.CENTER);
upButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
downButton.getModel().setPressed(true);
downButton.getModel().setSelected(true);
downButton.repaint();
}
@Override
public void mouseReleased(MouseEvent e) {
downButton.getModel().setPressed(false);
downButton.getModel().setSelected(false);
downButton.repaint();
}
@Override
public void mouseClicked(MouseEvent e) {
upButtonClickEvent();
}
});
downButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
upButton.getModel().setPressed(true);
upButton.getModel().setSelected(true);
upButton.repaint();
}
@Override
public void mouseReleased(MouseEvent e) {
upButton.getModel().setPressed(false);
upButton.getModel().setSelected(false);
upButton.repaint();
}
@Override
public void mouseClicked(MouseEvent e) {
downButtonClickEvent();
}
});
this.setLayout(new FlowLayout(FlowLayout.CENTER,5,0));
this.add(upButton);
this.add(downButton);
}
public UIPreviewButton(Icon left, Icon right) {
this();
upButton.setIcon(left);
downButton.setIcon(right);
}
public UIButton getUpButton() {
return upButton;
}
public void setExtraPainted(boolean isExtraPainted) {
if (!isExtraPainted) {
upButton.setBackground(null);
downButton.setBackground(null);
upButton.setOpaque(false);
downButton.setOpaque(false);
}
}
public UIButton getDownButton() {
return downButton;
}
public void set4Toolbar() {
upButton.setNormalPainted(false);
downButton.setNormalPainted(false);
upButton.setBorderPaintedOnlyWhenPressed(true);
downButton.setBorderPaintedOnlyWhenPressed(true);
}
protected void showPopWindow(JPopupMenu menu) {
GUICoreUtils.showPopupMenu(menu, this, START_X, getY() + getHeight() - 3);
}
public static void main(String... args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(null);
UIPreviewButton bb = new UIPreviewButton(UIConstants.PAGE_BIG_ICON, UIConstants.PREVIEW_DOWN);
bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height);
content.add(bb);
GUICoreUtils.centerWindow(jf);
jf.setSize(100, 100);
jf.setVisible(true);
}
} |
package com.fr.design.gui.ibutton;
import com.fr.design.constants.UIConstants;
import com.fr.stable.Constants;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* Author : daisy
* Date: 13-8-1
* Time: 下午3:41
*/
public class UIPreviewButton extends JPanel {
private static final int START_X = -7;
protected UIButton upButton;
protected UIButton downButton;
protected void upButtonClickEvent() {
// do nothing
}
protected void downButtonClickEvent() {
// do nothing
}
public UIPreviewButton() {
this(new UIButton(), new UIButton());
}
public UIPreviewButton(UIButton up, UIButton down) {
upButton = up;
downButton = down;
upButton.setRoundBorder(true, Constants.CENTER);
downButton.setRoundBorder(true, Constants.CENTER);
upButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
downButton.getModel().setPressed(true);
downButton.getModel().setSelected(true);
downButton.repaint();
}
@Override
public void mouseReleased(MouseEvent e) {
downButton.getModel().setPressed(false);
downButton.getModel().setSelected(false);
downButton.repaint();
}
@Override
public void mouseClicked(MouseEvent e) {
upButtonClickEvent();
}
});
downButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
upButton.getModel().setPressed(true);
upButton.getModel().setSelected(true);
upButton.repaint();
}
@Override
public void mouseReleased(MouseEvent e) {
upButton.getModel().setPressed(false);
upButton.getModel().setSelected(false);
upButton.repaint();
}
@Override
public void mouseClicked(MouseEvent e) {
downButtonClickEvent();
}
});
this.setLayout(new FlowLayout(FlowLayout.CENTER,5,0));
this.add(upButton);
this.add(downButton);
}
public UIPreviewButton(Icon left, Icon right) {
this();
upButton.setIcon(left);
downButton.setIcon(right);
}
public UIButton getUpButton() {
return upButton;
}
public void setExtraPainted(boolean isExtraPainted) {
if (!isExtraPainted) {
upButton.setBackground(null);
downButton.setBackground(null);
upButton.setOpaque(false);
downButton.setOpaque(false);
}
}
public UIButton getDownButton() {
return downButton;
}
public void set4Toolbar() {
upButton.setNormalPainted(false);
downButton.setNormalPainted(false);
upButton.setBorderPaintedOnlyWhenPressed(true);
downButton.setBorderPaintedOnlyWhenPressed(true);
}
protected void showPopWindow(JPopupMenu menu) {
GUICoreUtils.showPopupMenu(menu, this, START_X, getY() + getHeight() - 3);
}
public static void main(String... args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(null);
UIPreviewButton bb = new UIPreviewButton(UIConstants.PAGE_BIG_ICON, UIConstants.PREVIEW_DOWN);
bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height);
content.add(bb);
GUICoreUtils.centerWindow(jf);
jf.setSize(100, 100);
jf.setVisible(true);
}
} |
@ -1,53 +0,0 @@ |
|||||||
package com.fr.design.gui.itextfield; |
|
||||||
|
|
||||||
import java.awt.Graphics; |
|
||||||
|
|
||||||
import javax.swing.plaf.metal.MetalTextFieldUI; |
|
||||||
import javax.swing.text.JTextComponent; |
|
||||||
|
|
||||||
import de.muntjak.tinylookandfeel.Theme; |
|
||||||
|
|
||||||
public class TextFieldUI extends MetalTextFieldUI { |
|
||||||
|
|
||||||
|
|
||||||
protected void paintBackground(Graphics g) { |
|
||||||
JTextComponent editor = getComponent(); |
|
||||||
// We will only be here if editor is opaque, so we don't have to test
|
|
||||||
|
|
||||||
if(editor.isEnabled()) { |
|
||||||
if(editor.isEditable()) { |
|
||||||
g.setColor(editor.getBackground()); |
|
||||||
} |
|
||||||
else { |
|
||||||
// not editable
|
|
||||||
if(editor.getBackground().equals(Theme.textBgColor[Theme.style].getColor())) { |
|
||||||
// set default panel background
|
|
||||||
g.setColor(Theme.backColor[Theme.style].getColor()); |
|
||||||
} |
|
||||||
else { |
|
||||||
// color changed by user - set textfield background
|
|
||||||
g.setColor(editor.getBackground()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
g.fillRect(0, 0, editor.getWidth(), editor.getHeight()); |
|
||||||
} |
|
||||||
else { |
|
||||||
if(editor.getBackground().equals(Theme.textBgColor[Theme.style].getColor())) { |
|
||||||
g.setColor(Theme.textDisabledBgColor[Theme.style].getColor()); |
|
||||||
} |
|
||||||
else { |
|
||||||
// color changed by user - set textfield background
|
|
||||||
g.setColor(editor.getBackground()); |
|
||||||
} |
|
||||||
|
|
||||||
g.fillRect(0, 0, editor.getWidth(), editor.getHeight()); |
|
||||||
|
|
||||||
if(Theme.style != Theme.YQ_STYLE) return; |
|
||||||
|
|
||||||
g.setColor(Theme.backColor[Theme.style].getColor()); |
|
||||||
g.drawRect(1, 1, editor.getWidth() - 3, editor.getHeight() - 3); |
|
||||||
g.drawRect(2, 2, editor.getWidth() - 5, editor.getHeight() - 5); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue