📄 jprincipalapp.java
字号:
constMyView = viewClass.getConstructor(new Class[] {AppView.class, UserView.class}); myProcess = constMyView.newInstance(new Object[] {m_appview, JPrincipalApp.this}); } catch (NoSuchMethodException e) { } // 3er constructor y ultima oportunidad, por ello no va en try-catch if (constMyView == null) { constMyView = viewClass.getConstructor(new Class[] {AppView.class}); myProcess = constMyView.newInstance(new Object[] {m_appview}); } m_aCreatedProcess.put(m_sMyView, myProcess); } // ejecuto la tarea try { MessageInf m = myProcess.execute(); if (m != null) { // si devuelve un mensaje, lo muestro JMessageDialog.showMessage(JPrincipalApp.this, m); } } catch (BasicException eb) { // Si se produce un error lo muestro. JMessageDialog.showMessage(JPrincipalApp.this, new MessageInf(eb)); } } catch (Exception e) { JMessageDialog.showMessage(JPrincipalApp.this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("Label.LoadError"), e)); // } catch (ClassNotFoundException eCNF) {// } catch (NoSuchMethodException eNSM) {// } catch (SecurityException eS) {// } catch (InstantiationException eI) {// } catch (IllegalAccessException eIA) {// } catch (IllegalArgumentException eIAr) {// } catch (InvocationTargetException eIT) { } } else { // No hay permisos para ejecutar la accion... JMessageDialog.showMessage(JPrincipalApp.this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.notpermissions"))); } m_appview.waitCursorEnd(); } } private class ExitAction extends AbstractAction { public ExitAction(String icon, String keytext) { putValue(Action.SMALL_ICON, new ImageIcon(JPrincipalApp.class.getResource(icon))); putValue(Action.NAME, AppLocal.getIntString(keytext)); putValue(UserView.ACTION_TASKNAME, keytext); } public void actionPerformed(ActionEvent evt) { m_appview.closeAppView(JPrincipalApp.this); } } // La accion de cambio de password.. private class ChangePasswordAction extends AbstractAction { public ChangePasswordAction(String icon, String keytext) { putValue(Action.SMALL_ICON, new ImageIcon(JPrincipalApp.class.getResource(icon))); putValue(Action.NAME, AppLocal.getIntString(keytext)); putValue(UserView.ACTION_TASKNAME, keytext); } public void actionPerformed(ActionEvent evt) { String sNewPassword = Hashcypher.changePassword(JPrincipalApp.this, m_appuser.getPassword());// String sNewPassword = JDlgChangePassword.showMessage(JPrincipalApp.this, m_appuser.getPassword()); if (sNewPassword != null) { try { m_appview.lookupDataLogic(DataLogicSystem.class).execChangePassword(new Object[] {sNewPassword, m_appuser.getName()}); m_appuser.setPassword(sNewPassword); } catch (BasicException e) { JMessageDialog.showMessage(JPrincipalApp.this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotchangepassword"))); } } } } private void showView(String sView) { CardLayout cl = (CardLayout)(m_jPanelContainer.getLayout()); cl.show(m_jPanelContainer, sView); } public AppUser getUser() { return m_appuser; } public boolean showTask(String sTaskClass, Object params) { m_appview.waitCursorBegin(); if (m_appuser.hasPermission(sTaskClass)) { JPanelView m_jMyView = (JPanelView) m_aCreatedViews.get(sTaskClass); // cierro la antigua if ((m_jLastView != null && m_jMyView != m_jLastView && m_jLastView.deactivate()) || m_jLastView == null) { // Primero me construyo if (m_jMyView == null) { try { Class viewClass = Class.forName(sTaskClass); Constructor constMyView = null; // 1er constructor try { constMyView = viewClass.getConstructor(new Class[] {AppView.class, UserView.class, Object.class}); m_jMyView = (JPanelView) constMyView.newInstance(new Object[] {m_appview, this, params}); } catch (NoSuchMethodException e) { } // 2 constructor if (constMyView == null) { try { constMyView = viewClass.getConstructor(new Class[] {AppView.class, UserView.class}); m_jMyView = (JPanelView) constMyView.newInstance(new Object[] {m_appview, this}); } catch (NoSuchMethodException e) { } // 3er constructor y ultima oportunidad, por ello no va en try-catch if (constMyView == null) { constMyView = viewClass.getConstructor(new Class[] {AppView.class}); m_jMyView = (JPanelView) constMyView.newInstance(new Object[] {m_appview}); } } } catch (Exception e) { m_jMyView = new JPanelNull(m_appview, e); // } catch (ClassNotFoundException eCNF) { // } catch (NoSuchMethodException eNSM) { // } catch (SecurityException eS) { // } catch (InstantiationException eI) { // } catch (IllegalAccessException eIA) { // } catch (IllegalArgumentException eIAr) { // } catch (InvocationTargetException eIT) { } m_jPanelContainer.add(m_jMyView.getComponent(), sTaskClass); m_aCreatedViews.put(m_jMyView, sTaskClass); } // ejecuto la tarea try { m_jMyView.activate(); } catch (BasicException e) { JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.notactive"), e)); } // se tiene que mostrar el panel m_jLastView = m_jMyView; showView(sTaskClass); // Y ahora que he cerrado la antigua me abro yo String sTitle = m_jMyView.getTitle(); m_jPanelTitle.setVisible(sTitle != null); m_jTitle.setText(sTitle); m_appview.waitCursorEnd(); return true; } else { m_appview.waitCursorEnd(); return false; } } else { // No hay permisos para ejecutar la accion... JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.notpermissions"))); m_appview.waitCursorEnd(); return false; } } private class JPrincipalNotificator extends javax.swing.JPanel { private javax.swing.JLabel jLabel1; public JPrincipalNotificator() { initComponents(); jLabel1.setText(m_appuser.getName()); jLabel1.setIcon(m_appuser.getIcon()); } private void initComponents() { jLabel1 = new javax.swing.JLabel(); setLayout(new java.awt.BorderLayout()); setBorder(new javax.swing.border.CompoundBorder(new javax.swing.border.LineBorder(java.awt.Color.lightGray), new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 5, 1, 5)))); add(jLabel1, java.awt.BorderLayout.WEST); } } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { jSplitPane1 = new javax.swing.JSplitPane(); jPanel1 = new javax.swing.JPanel(); m_jPanelLeft = new javax.swing.JScrollPane(); m_jPanelRight = new javax.swing.JPanel(); m_jPanelTitle = new javax.swing.JPanel(); m_jTitle = new javax.swing.JLabel(); m_jPanelContainer = new javax.swing.JPanel(); setLayout(new java.awt.BorderLayout()); jSplitPane1.setDividerLocation(220); jSplitPane1.setDividerSize(8); jPanel1.setLayout(new java.awt.BorderLayout()); jPanel1.add(m_jPanelLeft, java.awt.BorderLayout.CENTER); jSplitPane1.setLeftComponent(jPanel1); m_jPanelRight.setLayout(new java.awt.BorderLayout()); m_jPanelTitle.setLayout(new java.awt.BorderLayout()); m_jTitle.setFont(new java.awt.Font("SansSerif", 1, 18)); m_jTitle.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, java.awt.Color.darkGray), javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10))); m_jPanelTitle.add(m_jTitle, java.awt.BorderLayout.NORTH); m_jPanelRight.add(m_jPanelTitle, java.awt.BorderLayout.NORTH); m_jPanelContainer.setLayout(new java.awt.CardLayout()); m_jPanelRight.add(m_jPanelContainer, java.awt.BorderLayout.CENTER); jSplitPane1.setRightComponent(m_jPanelRight); add(jSplitPane1, java.awt.BorderLayout.CENTER); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel jPanel1; private javax.swing.JSplitPane jSplitPane1; private javax.swing.JPanel m_jPanelContainer; private javax.swing.JScrollPane m_jPanelLeft; private javax.swing.JPanel m_jPanelRight; private javax.swing.JPanel m_jPanelTitle; private javax.swing.JLabel m_jTitle; // End of variables declaration//GEN-END:variables }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -