You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.7 KiB
60 lines
1.7 KiB
package com.fr.design.utils; |
|
|
|
import com.fr.config.dao.DaoContext; |
|
import com.fr.config.dao.impl.LocalClassHelperDao; |
|
import com.fr.config.dao.impl.LocalEntityDao; |
|
import com.fr.config.dao.impl.LocalXmlEntityDao; |
|
import com.fr.design.ui.util.UIUtil; |
|
import com.fr.transaction.Configurations; |
|
import com.fr.transaction.LocalConfigurationHelper; |
|
|
|
import javax.swing.JFrame; |
|
import java.awt.Dimension; |
|
import java.awt.Frame; |
|
import java.awt.Toolkit; |
|
import java.util.function.Consumer; |
|
|
|
/** |
|
* 设计器的开发时工具 |
|
* 帮助进行 UI 页面的调试 |
|
* <p> |
|
* created by Harrison on 2022/05/23 |
|
**/ |
|
public class DevUtils { |
|
|
|
private static void prepare() { |
|
|
|
DaoContext.setEntityDao(new LocalEntityDao()); |
|
DaoContext.setClassHelperDao(new LocalClassHelperDao()); |
|
DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); |
|
Configurations.setHelper(new LocalConfigurationHelper()); |
|
} |
|
|
|
public static void show(Consumer<Frame> consumer) { |
|
|
|
DesignUtils.initLookAndFeel(); |
|
|
|
UIUtil.invokeLaterIfNeeded(() -> { |
|
|
|
JFrame frame = new JFrame("dev-util"); |
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); |
|
frame.setSize(dimension); |
|
|
|
consumer.accept(frame); |
|
|
|
frame.setVisible(true); |
|
}); |
|
|
|
} |
|
|
|
public static void main(String[] args) { |
|
|
|
DevUtils.prepare(); |
|
DevUtils.show(new Consumer<Frame>() { |
|
@Override |
|
public void accept(Frame frame) { |
|
} |
|
}); |
|
} |
|
}
|
|
|