📄 jfrmtpv.java
字号:
// Finalizamos con exito.
return true;
}
public static void main (String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
// try {
// // com.jtattoo.plaf.acryl.AcrylLookAndFeel.setTheme("Green", "INSERT YOUR LICENSE KEY HERE", "my company");
// UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel");
// // UIManager.setLookAndFeel("com.jtattoo.plaf.smart.SmartLookAndFeel");
// // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// } catch (Exception e) {
// }
JFrmTPV app = new JFrmTPV();
if (!app.startTPV()) {
// No se ha iniciado correctamente, entonces nos vamos con un disgusto.
System.exit(1);
}
}
});
}
private String getDataBaseVersion() {
try {
return lookupDataLogic(DataLogicSystem.class).findVersion();
} catch (BasicException ed) {
}
// Comprobamos si existe la base de datos
try {
lookupDataLogic(DataLogicSystem.class).execDummy();
return "0.0.7";
} catch (BasicException e) {
return "create";
}
}
// Interfaz de aplicacion
public DeviceTicket getDeviceTicket(){
return m_TP;
}
public DeviceScale getDeviceScale() {
return m_Scale;
}
public DeviceScanner getDeviceScanner() {
return m_Scanner;
}
public Session getSession() {
return m_appcnt.getSession();
}
public String getHost() {
return m_appcnt.getHost();
}
public Integer getInventoryLocation() {
return m_iInventoryLocation;
}
public Integer getActiveCashIndex() {
return m_iActiveCashIndex;
}
public Date getActiveCashDateStart() {
return m_dActiveCashDateStart;
}
public Date getActiveCashDateEnd(){
return m_dActiveCashDateEnd;
}
public void setActiveCash(Integer iIndex, Date dStart, Date dEnd) {
m_iActiveCashIndex = iIndex;
m_dActiveCashDateStart = dStart;
m_dActiveCashDateEnd = dEnd;
setMachineProperty("activecash", m_iActiveCashIndex.toString());
saveMachineProperties();
}
// Propiedades en base de datos
private void setMachineProperty(String sKey, String sValue) {
m_propsdb.setProperty(sKey, sValue);
}
private String getMachineProperty(String sKey) {
return m_propsdb.getProperty(sKey);
}
private void saveMachineProperties() {
lookupDataLogic(DataLogicSystem.class).setResourceAsProperties(getHost() + "/properties", m_propsdb);
}
public String getProperty(String sKey) {
return m_appcnt.getProperty(sKey);
}
public <T extends DataLogic> T lookupDataLogic(Class<T> clazz) {
return m_dataprovider.lookup(clazz);
}
public void restoreWindow() throws RemoteException {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
if (getExtendedState() == JFrame.ICONIFIED) {
setExtendedState(JFrame.NORMAL);
}
}
});
}
private void changeDisplayMode(int iwidth, int iheight) {
if ("fullscreen".equals(getProperty("machine.screenmode"))) {
// muestro la ventana
GraphicsDevice myDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
if (myDevice.isFullScreenSupported()) {
// Buscamos el modo que mejor se ajusta
// tiene que ser 1024 x 768 y mejor que 8 bpp y mejor que 60 hz
DisplayMode[] modes = myDevice.getDisplayModes();
DisplayMode bestDisplayMode = null;
int iBestRefreshRate = 60;
int iBestBitDepth = 16;
for (int i = 0; i < modes.length; i++) {
// if (modes[i].getWidth() == 1280 && modes[i].getHeight() == 1024) {
if (modes[i].getWidth() == iwidth && modes[i].getHeight() == iheight) {
if (modes[i].getBitDepth() != DisplayMode.BIT_DEPTH_MULTI && modes[i].getBitDepth() >= iBestBitDepth &&
modes[i].getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN && modes[i].getRefreshRate() >= iBestRefreshRate) {
bestDisplayMode = modes[i];
iBestRefreshRate = modes[i].getRefreshRate();
iBestBitDepth = modes[i].getBitDepth();
}
}
}
if (bestDisplayMode == null) {
JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, Integer.toString(iwidth) + "x" + Integer.toString(iheight) + " not supported." ));
} else {
if (myDevice.getDisplayMode().equals(bestDisplayMode)) {
// ya estamos en el modo adecuado
setUndecorated(true);
myDevice.setFullScreenWindow(this);
return; // terminamos
} else {
if (!myDevice.isDisplayChangeSupported()) {
try {
setUndecorated(true);
myDevice.setFullScreenWindow(this);
myDevice.setDisplayMode(bestDisplayMode);
return; // terminamos
} catch (IllegalArgumentException eIA) {
JMessageDialog.showMessage(this, new MessageInf(eIA));
}
} else {
JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, "Cannot change display mode"));
}
}
}
} else {
JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, "Full screen mode not supported"));
}
}
// No es pantalla completa.
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width - iwidth) / 2, (screenSize.height - iheight) / 2, iwidth, iheight);
// setExtendedState(JFrame.MAXIMIZED_BOTH);
}
private void printerStart() {
String sresource = lookupDataLogic(DataLogicSystem.class).getResourceAsXML("Printer.Start");
if (sresource == null) {
m_TP.writeTimeVisor(AppLocal.getIntString("Visor.Title")); // Pinto algo bonito para empezar
} else {
try {
m_TTP.printTicket(sresource);
} catch (TicketPrinterException eTP) {
m_TP.writeTimeVisor(AppLocal.getIntString("Visor.Title")); // Pinto algo bonito para empezar
}
}
}
private void listPeople() {
try {
jScrollPane1.getViewport().setView(null);
JFlowPanel jPeople = new JFlowPanel();
jPeople.setOpaque(false);
java.util.List people = lookupDataLogic(DataLogicSystem.class).listPeopleVisible();
Image defimg;
try {
defimg = ImageIO.read(getClass().getClassLoader().getResourceAsStream("net/adrianromero/images/yast_sysadmin.png"));
} catch (Exception fnfe) {
defimg = null;
}
ThumbNailBuilder tnb = new ThumbNailBuilder(32, 32, defimg);
for (int i = 0; i < people.size(); i++) {
Object[] value = (Object[]) people.get(i);
AppUser user = new AppUser(
new ImageIcon(tnb.getThumbNail((Image) value[3]))
, (String) value[0]
, (String) value[1]
, (String) value[2]);
JButton btn = new JButton(new AppUserAction(user));
btn.setFocusPainted(false);
btn.setFocusable(false);
btn.setRequestFocusEnabled(false);
btn.setHorizontalAlignment(SwingConstants.LEADING);
// btn.setMargin(new Insets(2, 2, 2, 2));
btn.setMaximumSize(new Dimension(150, 50));
btn.setPreferredSize(new Dimension(150, 50));
btn.setMinimumSize(new Dimension(150, 50));
jPeople.add(btn);
}
jScrollPane1.getViewport().setView(jPeople);
} catch (BasicException ee) {
ee.printStackTrace();
}
}
// La accion del selector
private class AppUserAction extends AbstractAction {
private AppUser m_actionuser;
public AppUserAction(AppUser user) {
m_actionuser = user;
putValue(Action.SMALL_ICON, m_actionuser.getIcon());
putValue(Action.NAME, m_actionuser.getName());
}
public AppUser getUser() {
return m_actionuser;
}
public void actionPerformed(ActionEvent evt) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -