List of usage examples for javax.swing JButton setFont
@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.") public void setFont(Font font)
From source file:Tcpbw100.java
public void init() { //added applet parameters (country,language) to directly influence the language displayed if (getParameter("country") != null) country = getParameter("country"); if (getParameter("language") != null) lang = getParameter("language"); if (getParameter("client") != null) applet_id = getParameter("client"); // try to load the appropriate resource files try {//from w w w. j a v a 2 s .c om locale = new Locale(lang, country); System.out.println("Interface language set to " + locale.getLanguage() + "_" + locale.getCountry()); messages = ResourceBundle.getBundle("Tcpbw100_msgs", locale); res = ResourceBundle.getBundle("strings", locale); System.out.println("language loaded is :" + res.getLocale()); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error while loading language files:\n" + e.getMessage()); e.printStackTrace(); } JPanel advancedPanel = new JPanel(new BorderLayout()); final CardLayout cards = new CardLayout(); getContentPane().setLayout(cards); final JFrame popout = new JFrame("Network Diagnostic Tool"); popout.add(advancedPanel); popout.pack(); //blank the labels reset_labels(); showStatus(messages.getString("ready")); failed = false; Randomize = false; cancopy = false; results = new MyTextPane(); results.append("TCP/Web100 Network Diagnostic Tool v" + VERSION + "\n"); results.setEditable(false); advancedPanel.add(new JScrollPane(results), BorderLayout.CENTER); results.append(messages.getString("clickStart") + "\n"); Panel mPanel = new Panel(); startTest = new JButton(messages.getString("start")); startTest.addActionListener(this); startTest2 = new JButton(res.getString("start")); startTest2.addActionListener(this); //mPanel.add(startTest); sTatistics = new JButton(messages.getString("statistics")); sTatistics.addActionListener(this); if (getParameter("disableStatistics") == null) { mPanel.add(sTatistics); } sTatistics.setEnabled(false); deTails = new JButton(messages.getString("moreDetails")); deTails.addActionListener(this); if (getParameter("disableDetails") == null) { mPanel.add(deTails); } deTails.setEnabled(false); mailTo = new JButton(messages.getString("reportProblem")); mailTo.addActionListener(this); if (getParameter("disableMailto") == null) { //mPanel.add(mailTo); } mailTo.setEnabled(false); options = new JButton(messages.getString("options") + "..."); options.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { options.setEnabled(false); showOptions(); options.setEnabled(true); } }); if (getParameter("disableOptions") == null) { mPanel.add(options); } advancedPanel.add(mPanel, BorderLayout.SOUTH); preferIPv6 = new JCheckBox(messages.getString("preferIPv6")); preferIPv6.setSelected(true); defaultTest = new JCheckBox(messages.getString("defaultTests")); defaultTest.setSelected(true); defaultTest.setEnabled(false); SpinnerNumberModel model = new SpinnerNumberModel(); model.setMinimum(new Integer(0)); model.setValue(new Integer(1)); numOfTests.setModel(model); numOfTests.setPreferredSize(new Dimension(60, 20)); delay = new JComboBox(); for (int i = 0; i < delays.length; i++) { delay.addItem(messages.getString(delays[i])); } delay.setSelectedIndex(0); //Autorun functionality isAutoRun = getParameter("autoRun"); if ((isAutoRun != null) && isAutoRun.equals("true")) { pub_errmsg = "Test in progress."; runtest(); } //@@@ getContentPane().add(advancedPanel,""); //try to load the calibri font for the simplified interface. //this will not cause problems even if said font is not available Font very_small_font = new Font("Calibri", Font.PLAIN, 6); Font small_font = new Font("Calibri", Font.PLAIN, 14); Font big_font = new Font("Calibri", Font.PLAIN, 18); startTest2.setFont(small_font); //simplePanel will be the new face of the applet JPanel simplePanel = new JPanel(); simplePanel.setLayout(null); simplePanel.setBackground(Color.WHITE); //simplePanel.setLayout(new BorderLayout()); simplePanel.add(simple_progressBar, BorderLayout.SOUTH); getContentPane().add(simplePanel, ""); cards.last(getContentPane()); simple_progressBar.setMaximum(10); simple_progressBar.setBounds(3, 135, 394, 23); simple_progressBar.setFont(small_font); //simple_progressBar.setIndeterminate(true); simple_progressBar.setIndeterminate(false); simple_progressBar.setValue(0); simple_progressBar.setStringPainted(true); simple_progressBar.setString(res.getString("ready_to_measure")); //position the startTest2 button explicitly //was: simplePanel.add(startTest2,BorderLayout.NORTH); simplePanel.add(startTest2, ""); startTest2.setBounds(3, 164, 195, 30); final class switcherListener implements ActionListener { public void actionPerformed(ActionEvent e) { //@@@cards.next(getContentPane()); if (popout.isVisible()) { popout.setVisible(false); } else { popout.setVisible(true); popout.pack(); } } } //"show details button" - activates the classic NDT interface JButton switchPane = new JButton(res.getString("show_details")); switchPane.setFont(small_font); switchPane.addActionListener(new switcherListener()); simplePanel.add(switchPane, ""); switchPane.setBounds(202, 164, 195, 30); //masterArea, displays the measurement characteristics JPanel masterArea = new JPanel(new GridLayout(0, 2)); //position explicitly simplePanel.add(masterArea, ""); masterArea.setBounds(1, 1, 398, 130); masterArea.setBackground(Color.WHITE); //create the 5 tags that will be placed in the masterArea JLabel dnlTag = new JLabel(res.getString("download")); JLabel uplTag = new JLabel(res.getString("upload")); JLabel rttTag = new JLabel(res.getString("ping")); JLabel lossTag = new JLabel(res.getString("loss")); JLabel jitterTag = new JLabel(res.getString("jitter")); //make the masterAre pretty dnlTag.setHorizontalAlignment(JLabel.RIGHT); uplTag.setHorizontalAlignment(JLabel.RIGHT); rttTag.setHorizontalAlignment(JLabel.RIGHT); lossTag.setHorizontalAlignment(JLabel.RIGHT); jitterTag.setHorizontalAlignment(JLabel.RIGHT); dnlTag.setFont(big_font); uplTag.setFont(big_font); rttTag.setFont(big_font); lossTag.setFont(big_font); jitterTag.setFont(big_font); dnlLbl.setHorizontalAlignment(JLabel.LEFT); uplLbl.setHorizontalAlignment(JLabel.LEFT); rttLbl.setHorizontalAlignment(JLabel.LEFT); lossLbl.setHorizontalAlignment(JLabel.LEFT); jitterLbl.setHorizontalAlignment(JLabel.LEFT); dnlLbl.setFont(big_font); uplLbl.setFont(big_font); rttLbl.setFont(big_font); lossLbl.setFont(big_font); jitterLbl.setFont(big_font); //and finally, place the labels masterArea.add(dnlTag); masterArea.add(dnlLbl); masterArea.add(uplTag); masterArea.add(uplLbl); masterArea.add(rttTag); masterArea.add(rttLbl); masterArea.add(lossTag); masterArea.add(lossLbl); masterArea.add(jitterTag); masterArea.add(jitterLbl); // determine whether to prefer IPv6 or not, this is done only once if (getParameter("disable_ipv6") != null) { preferIPv6.setSelected(false); } }
From source file:Form.Principal.java
public void PanelUsuarios() { int i = 0;/*from w w w . j a va 2s . co m*/ int Altura = 0; Color gris = new Color(44, 44, 44); Color azul = new Color(0, 153, 255); Color rojo = new Color(221, 76, 76); try { //Consultamos todos los clientes ResultSet Comandos = Funcion.Select(st, "SELECT * FROM usuarios where Tipo!='Administrador';"); //Ciclo para crear un panel para cada uno while (Comandos.next()) { //Creamos un panel con alineacion a la izquierda JPanel Panel = new JPanel(); Panel.setLayout(null); jPanel12.add(Panel); //Tamao del panel Panel.setSize(500, 200); // La posicion y del panel ira incrementando para que no se encimen Altura = 40 + (i * 220); Panel.setLocation(175, Altura); Panel.setBackground(Color.white); Panel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); //Creamos label para mostrar los datos del cliente, el codigo html es para que al llegar al final del panel //se pase a la siguiente linea y para el margen izquierdo JLabel Foto = new JLabel(); Foto.setSize(150, 150); File FotoPerfil = new File("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".png"); File FotoPerfil2 = new File("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".jpg"); if (FotoPerfil.exists()) { ImageIcon Imagen = new ImageIcon("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".png"); Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(), Image.SCALE_SMOOTH); Icon IconoEscalado = new ImageIcon(ImagenEscalada); Foto.setIcon(IconoEscalado); } else if (FotoPerfil2.exists()) { ImageIcon Imagen = new ImageIcon("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".jpg"); Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(), Image.SCALE_SMOOTH); Icon IconoEscalado = new ImageIcon(ImagenEscalada); Foto.setIcon(IconoEscalado); } else { ImageIcon Imagen = new ImageIcon(getClass().getResource("/Imagen/Default.png")); Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(), Image.SCALE_SMOOTH); Icon IconoEscalado = new ImageIcon(ImagenEscalada); Foto.setIcon(IconoEscalado); } JLabel Nombre = new JLabel(); Nombre.setText("Nombre de Usuario: " + Comandos.getString("Nombre")); JLabel Contrasena = new JLabel(); Contrasena.setText(("Contrasea: " + Comandos.getString("contrasena"))); JButton Editar = new JButton(); Editar.setText("Editar"); Editar.setName(Comandos.getString("id")); Editar.setBackground(azul); JButton Eliminar = new JButton(); Eliminar.setText("Eliminar"); Eliminar.setName(Comandos.getString("id")); Eliminar.setBackground(rojo); MouseListener mlEditar = new MouseListener() { @Override public void mouseReleased(MouseEvent e) { //System.out.println("Released!"); } @Override public void mousePressed(MouseEvent e) { //System.out.println("Pressed!"); } @Override public void mouseExited(MouseEvent e) { //System.out.println("Exited!"); } @Override public void mouseEntered(MouseEvent e) { //System.out.println("Entered!"); } @Override public void mouseClicked(MouseEvent e) { presionadoactual = 24; Color azul = new Color(0, 182, 230); jButton24.setBackground(azul); JButton source = (JButton) e.getSource(); System.out.println(source.getName()); jPanel17.setVisible(false); jButton30.setLocation(470, 480); jButton31.setLocation(270, 480); jLabel2.setToolTipText(null); jTabbedPane2.setSelectedIndex(5); editando = true; PerfilUsuario(Integer.parseInt(source.getName())); Color gris = new Color(44, 44, 44); jButton4.setBackground(gris); } }; MouseListener mlEliminar = new MouseListener() { @Override public void mouseReleased(MouseEvent e) { //System.out.println("Released!"); } @Override public void mousePressed(MouseEvent e) { //System.out.println("Pressed!"); } @Override public void mouseExited(MouseEvent e) { //System.out.println("Exited!"); } @Override public void mouseEntered(MouseEvent e) { //System.out.println("Entered!"); } @Override public void mouseClicked(MouseEvent e) { JButton source = (JButton) e.getSource(); System.out.println(source.getName()); Funcion.Update(st, "DELETE FROM usuarios WHERE id = " + source.getName() + ";"); jPanel12.removeAll(); PanelUsuarios(); jPanel12.repaint(); } }; Editar.addMouseListener(mlEditar); Eliminar.addMouseListener(mlEliminar); //Fuente del texto; Nombre.setFont(new Font("Verdana", Font.PLAIN, 15)); Nombre.setForeground(gris); Contrasena.setFont(new Font("Verdana", Font.PLAIN, 15)); Contrasena.setForeground(gris); Editar.setFont(new Font("Verdana", Font.PLAIN, 15)); Editar.setForeground(Color.white); Eliminar.setFont(new Font("Verdana", Font.PLAIN, 15)); Eliminar.setForeground(Color.white); //Aadimos los label al panel correspondiente del cliente Panel.add(Foto); Panel.add(Nombre); Panel.add(Contrasena); Panel.add(Editar); Panel.add(Eliminar); Foto.setLocation(10, 20); Nombre.setLocation(170, 30); Nombre.setSize(300, 45); Contrasena.setLocation(170, 60); Contrasena.setSize(300, 45); Editar.setLocation(170, 100); Editar.setSize(120, 40); Eliminar.setLocation(315, 100); Eliminar.setSize(120, 40); i++; } } catch (SQLException ex) { Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex); } //Dependiendo de cuantos clientes se agregaron, se ajusta el tamao del panel principal para que el scroll llegue hasta ahi jPanel12.setPreferredSize(new Dimension(jPanel12.getWidth(), Altura + 150)); }
From source file:Form.Principal.java
public void PanelClientes() { int i = 0;/* www . j av a2s. c om*/ int Altura = 0; Color gris = new Color(44, 44, 44); Color rojo = new Color(221, 76, 76); Color azul = new Color(0, 153, 255); try { //Consultamos todos los clientes ResultSet Comandos = Funcion.Select(st, "SELECT * FROM cliente;"); //Ciclo para crear un panel para cada uno while (Comandos.next()) { //Creamos un panel con alineacion a la izquierda JPanel Panel = new JPanel(); Panel.setLayout(null); jPanel8.add(Panel); //Tamao del panel Panel.setSize(700, 195); // La posicion y del panel ira incrementando para que no se encimen Altura = 30 + (i * 205); Panel.setLocation(50, Altura); Panel.setBackground(Color.white); Panel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); //Creamos label para mostrar los datos del cliente, el codigo html es para que al llegar al final del panel //se pase a la siguiente linea y para el margen izquierdo JLabel RFC = new JLabel(); RFC.setText("RFC: " + Comandos.getString("RFC")); JLabel Nombre = new JLabel(); Nombre.setText("Nombre: " + Comandos.getString("NombreCliente")); JTextArea Direccion = new JTextArea(); Direccion.setLineWrap(true); Direccion.setBorder(null); Direccion.setText("Direccin: " + Comandos.getString("Direccion")); JLabel Correo = new JLabel(); Correo.setText("Correo: " + Comandos.getString("correo")); JButton VerMas = new JButton(); VerMas.setText("Ver ms"); VerMas.setName(Comandos.getString("idCliente")); VerMas.setBackground(azul); JButton Eliminar = new JButton(); Eliminar.setText("Eliminar"); Eliminar.setName(Comandos.getString("idCliente")); Eliminar.setBackground(rojo); MouseListener mlVerMas = new MouseListener() { @Override public void mouseReleased(MouseEvent e) { //System.out.println("Released!"); } @Override public void mousePressed(MouseEvent e) { //System.out.println("Pressed!"); } @Override public void mouseExited(MouseEvent e) { //System.out.println("Exited!"); } @Override public void mouseEntered(MouseEvent e) { //System.out.println("Entered!"); e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } @Override public void mouseClicked(MouseEvent e) { JButton source = (JButton) e.getSource(); id = Integer.parseInt(source.getName()); jTabbedPane2.setSelectedIndex(4); jButton16.setVisible(true); jButton17.setVisible(true); jButtonEditar.setVisible(true); jPanel9.setVisible(true); jPanel10.setVisible(true); jPanel14.setVisible(false); LlenarPanel(); } }; VerMas.addMouseListener(mlVerMas); MouseListener mlEliminar = new MouseListener() { @Override public void mouseReleased(MouseEvent e) { //System.out.println("Released!"); } @Override public void mousePressed(MouseEvent e) { //System.out.println("Pressed!"); } @Override public void mouseExited(MouseEvent e) { //System.out.println("Exited!"); } @Override public void mouseEntered(MouseEvent e) { //System.out.println("Entered!"); e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } @Override public void mouseClicked(MouseEvent e) { JButton source = (JButton) e.getSource(); Funcion.Update(st, "DELETE FROM cliente WHERE idCliente = " + source.getName() + ";"); Autocompletar.removeAllItems(); Autocompletar = new TextAutoCompleter(jTextField2); ResultSet Comandos = Funcion.Select(st, "SELECT * FROM cliente;"); try { while (Comandos.next()) { Autocompletar.addItem(Comandos.getString("RFC")); } } catch (SQLException ex) { //Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex); } jPanel8.removeAll(); PanelClientes(); jPanel8.repaint(); } }; Eliminar.addMouseListener(mlEliminar); //Fuente del texto RFC.setFont(new Font("Verdana", Font.PLAIN, 14)); RFC.setForeground(gris); Nombre.setFont(new Font("Verdana", Font.PLAIN, 14)); Nombre.setForeground(gris); Direccion.setFont(new Font("Verdana", Font.PLAIN, 14)); Direccion.setForeground(gris); Correo.setFont(new Font("Verdana", Font.PLAIN, 14)); Correo.setForeground(gris); VerMas.setFont(new Font("Verdana", Font.PLAIN, 14)); VerMas.setForeground(Color.white); Eliminar.setFont(new Font("Verdana", Font.PLAIN, 14)); Eliminar.setForeground(Color.white); /*VERMAS.setFont(new Font("Verdana", Font.PLAIN, 13)); VERMAS.setForeground(azul);*/ //Aadimos los label al panel correspondiente del cliente Panel.add(RFC); Panel.add(Nombre); Panel.add(Direccion); Panel.add(Correo); Panel.add(VerMas); Panel.add(Eliminar); RFC.setLocation(30, 10); RFC.setSize(610, 30); Nombre.setLocation(30, 40); Nombre.setSize(610, 30); Direccion.setLocation(30, 75); Direccion.setSize(610, 40); Correo.setLocation(30, 115); Correo.setSize(610, 30); VerMas.setLocation(210, 150); VerMas.setSize(120, 35); Eliminar.setLocation(390, 150); Eliminar.setSize(120, 35); //Panel.add(VERMAS); i++; } } catch (SQLException ex) { Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex); } //Dependiendo de cuantos clientes se agregaron, se ajusta el tamao del panel principal para que el scroll llegue hasta ahi jPanel8.setPreferredSize(new Dimension(jPanel8.getWidth(), Altura + 205)); }
From source file:Form.Principal.java
public void PanelFacturas() { int i = 0;//from ww w . j a v a2 s . c o m int Altura = 0; Color gris = new Color(44, 44, 44); Color azul = new Color(0, 153, 255); Color rojo = new Color(221, 76, 76); try { //Consultamos todos los clientes ResultSet Comandos = Funcion.Select(st, "SELECT factura_emitida.*, cliente.* FROM cliente,factura_emitida WHERE factura_emitida.idCliente = cliente.idCliente;"); //Ciclo para crear un panel para cada uno while (Comandos.next()) { Variables.Comentario = Comandos.getString("Observaciones"); //Creamos un panel con alineacion a la izquierda JPanel Panel = new JPanel(); Panel.setLayout(null); jPanel11.add(Panel); //Tamao del panel Panel.setSize(680, 200); // La posicion y del panel ira incrementando para que no se encimen Altura = 30 + (i * 250); Panel.setLocation(50, Altura); Panel.setBackground(Color.white); Panel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); //Creamos label para mostrar los datos del cliente, el codigo html es para que al llegar al final del panel //se pase a la siguiente linea y para el margen izquierdo JLabel FolioFactura = new JLabel(); FolioFactura.setText("Folio de factura: " + Comandos.getString("idFacturaEmitida")); JLabel RFC = new JLabel(); RFC.setText("RFC: " + Comandos.getString("RFC")); JLabel Nombre = new JLabel(); Nombre.setText("Nombre: " + Comandos.getString("NombreCliente")); JLabel Direccion = new JLabel(); Direccion.setText("Direccion: " + Comandos.getString("Direccion")); JLabel Correo = new JLabel(); Correo.setText("Correo: " + Comandos.getString("correo")); JLabel Fecha = new JLabel(); Fecha.setText("Fecha y Hora de emisin: " + Comandos.getString("FechaEmision")); JButton Abre = new JButton(); Abre.setText("Abrir"); Abre.setName(Comandos.getString("idFacturaEmitida")); Abre.setBackground(azul); JButton Cancelar = new JButton(); Cancelar.setText("Cancelar"); Cancelar.setName(Comandos.getString("idFacturaEmitida")); Cancelar.setBackground(rojo); MouseListener mlAbre = new MouseListener() { @Override public void mouseReleased(MouseEvent e) { //System.out.println("Released!"); } @Override public void mousePressed(MouseEvent e) { //System.out.println("Pressed!"); } @Override public void mouseExited(MouseEvent e) { //System.out.println("Exited!"); } @Override public void mouseEntered(MouseEvent e) { //System.out.println("Entered!"); } @Override public void mouseClicked(MouseEvent e) { try { JButton source = (JButton) e.getSource(); idFacClien = Integer.parseInt(source.getName()); ResultSet Comandos = Funcion.Select(st, "SELECT *FROM factura_emitida WHERE idfacturaEmitida=" + idFacClien + ";"); while (Comandos.next()) { Variables.FechaFactura = Comandos.getString("FechaEmision"); Variables.FechaSistema = Comandos.getString("fechasistema"); Variables.idFactura = Comandos.getInt("idFacturaEmitida"); } Consulta(); Variables.guardar = false; NuevoPdf pdf = new NuevoPdf("Factura.pdf"); pdf.main(); File myfile = new File("Factura.pdf"); Desktop.getDesktop().open(myfile); Comandos = Funcion.Select(st, "SELECT * FROM factura_emitida;"); try { if (Comandos.next()) { Comandos.last(); Variables.idFactura = Comandos.getInt("idFacturaEmitida") + 1; } else { Variables.idFactura = 1; } } catch (SQLException ex) { Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex); } } catch (Exception ex) { Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex); } } }; MouseListener mlCancelar = new MouseListener() { @Override public void mouseReleased(MouseEvent e) { //System.out.println("Released!"); } @Override public void mousePressed(MouseEvent e) { //System.out.println("Pressed!"); } @Override public void mouseExited(MouseEvent e) { //System.out.println("Exited!"); } @Override public void mouseEntered(MouseEvent e) { //System.out.println("Entered!"); } @Override public void mouseClicked(MouseEvent e) { JButton source = (JButton) e.getSource(); Variables.Cancelar = Integer.parseInt(source.getName()); String Comando = "UPDATE factura_emitida SET Observaciones='Factura Cancelada' WHERE idFacturaEmitida=" + Variables.Cancelar + ";"; Funcion.Update(st, Comando); jPanel11.removeAll(); PanelFacturas(); jPanel11.repaint(); } }; Abre.addMouseListener(mlAbre); Cancelar.addMouseListener(mlCancelar); //Fuente del texto; FolioFactura.setFont(new Font("Verdana", Font.PLAIN, 13)); FolioFactura.setForeground(gris); RFC.setFont(new Font("Verdana", Font.PLAIN, 13)); RFC.setForeground(gris); Nombre.setFont(new Font("Verdana", Font.PLAIN, 13)); Nombre.setForeground(gris); Direccion.setFont(new Font("Verdana", Font.PLAIN, 13)); Direccion.setForeground(gris); Correo.setFont(new Font("Verdana", Font.PLAIN, 13)); Correo.setForeground(gris); Fecha.setFont(new Font("Verdana", Font.PLAIN, 13)); Fecha.setForeground(gris); /// Botones Abre.setFont(new Font("Verdana", Font.PLAIN, 15)); Abre.setForeground(Color.white); Cancelar.setFont(new Font("Verdana", Font.PLAIN, 15)); Cancelar.setForeground(Color.white); //Aadimos los label al panel correspondiente del cliente Panel.add(FolioFactura); Panel.add(RFC); Panel.add(Nombre); Panel.add(Direccion); Panel.add(Correo); Panel.add(Fecha); Panel.add(Abre); FolioFactura.setLocation(15, 5); FolioFactura.setSize(400, 45); RFC.setLocation(15, 25); RFC.setSize(400, 45); Nombre.setLocation(15, 45); Nombre.setSize(500, 45); Direccion.setLocation(15, 65); Direccion.setSize(650, 45); Correo.setLocation(15, 85); Correo.setSize(500, 45); Fecha.setLocation(15, 105); Fecha.setSize(500, 45); /// Botones Tamao y localizacion if (Variables.Tipo.equalsIgnoreCase("Administrador")) { // Verificamos que sea un Administrador Panel.add(Cancelar); Abre.setLocation(185, 160); Abre.setSize(120, 30); Cancelar.setLocation(350, 160); Cancelar.setSize(120, 30); if (Variables.Comentario.equalsIgnoreCase("Factura Cancelada")) { Cancelar.setVisible(false); Abre.setLocation(290, 160); Abre.setSize(120, 30); } } else { Abre.setLocation(290, 160); Abre.setSize(120, 30); } i++; } } catch (SQLException ex) { Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex); } //Dependiendo de cuantos clientes se agregaron, se ajusta el tamao del panel principal para que el scroll llegue hasta ahi jPanel11.setPreferredSize(new Dimension(jPanel11.getWidth(), Altura + 300)); }
From source file:net.technicpack.launcher.ui.LauncherFrame.java
private void initComponents() { BorderLayout layout = new BorderLayout(); setLayout(layout);//from ww w. jav a 2s. com ///////////////////////////////////////////////////////////// //HEADER ///////////////////////////////////////////////////////////// JPanel header = new JPanel(); header.setLayout(new BoxLayout(header, BoxLayout.LINE_AXIS)); header.setBackground(COLOR_BLUE); header.setForeground(COLOR_WHITE_TEXT); header.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10)); this.add(header, BorderLayout.PAGE_START); ImageIcon headerIcon = resources.getIcon("platform_icon_title.png"); JButton headerLabel = new JButton(headerIcon); headerLabel.setBorder(BorderFactory.createEmptyBorder(5, 8, 5, 0)); headerLabel.setContentAreaFilled(false); headerLabel.setFocusPainted(false); headerLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); headerLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DesktopUtils.browseUrl("http://beta.technicpack.net/"); } }); header.add(headerLabel); header.add(Box.createRigidArea(new Dimension(6, 0))); ActionListener tabListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectTab(e.getActionCommand()); } }; discoverTab = new HeaderTab(resources.getString("launcher.title.discover"), resources); header.add(discoverTab); discoverTab.setActionCommand(TAB_DISCOVER); discoverTab.addActionListener(tabListener); modpacksTab = new HeaderTab(resources.getString("launcher.title.modpacks"), resources); modpacksTab.setIsActive(true); modpacksTab.setHorizontalTextPosition(SwingConstants.LEADING); modpacksTab.addActionListener(tabListener); modpacksTab.setActionCommand(TAB_MODPACKS); header.add(modpacksTab); newsTab = new HeaderTab(resources.getString("launcher.title.news"), resources); newsTab.setLayout(null); newsTab.addActionListener(tabListener); newsTab.setActionCommand(TAB_NEWS); header.add(newsTab); CountCircle newsCircle = new CountCircle(); newsCircle.setBackground(COLOR_RED); newsCircle.setForeground(COLOR_WHITE_TEXT); newsCircle.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS_BOLD, 14)); newsTab.add(newsCircle); newsCircle.setBounds(10, 17, 25, 25); header.add(Box.createHorizontalGlue()); JPanel rightHeaderPanel = new JPanel(); rightHeaderPanel.setOpaque(false); rightHeaderPanel.setLayout(new BoxLayout(rightHeaderPanel, BoxLayout.PAGE_AXIS)); rightHeaderPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); JPanel windowGadgetPanel = new JPanel(); windowGadgetPanel.setOpaque(false); windowGadgetPanel.setLayout(new BoxLayout(windowGadgetPanel, BoxLayout.LINE_AXIS)); windowGadgetPanel.setAlignmentX(RIGHT_ALIGNMENT); ImageIcon minimizeIcon = resources.getIcon("minimize.png"); JButton minimizeButton = new JButton(minimizeIcon); minimizeButton.setBorder(BorderFactory.createEmptyBorder()); minimizeButton.setContentAreaFilled(false); minimizeButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); minimizeButton.setFocusable(false); minimizeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { minimizeWindow(); } }); windowGadgetPanel.add(minimizeButton); ImageIcon closeIcon = resources.getIcon("close.png"); JButton closeButton = new JButton(closeIcon); closeButton.setBorder(BorderFactory.createEmptyBorder()); closeButton.setContentAreaFilled(false); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { closeWindow(); } }); closeButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); closeButton.setFocusable(false); windowGadgetPanel.add(closeButton); rightHeaderPanel.add(windowGadgetPanel); rightHeaderPanel.add(Box.createVerticalGlue()); JButton launcherOptionsLabel = new JButton(resources.getString("launcher.title.options")); launcherOptionsLabel.setIcon(resources.getIcon("options_cog.png")); launcherOptionsLabel.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 14)); launcherOptionsLabel.setForeground(COLOR_WHITE_TEXT); launcherOptionsLabel.setHorizontalAlignment(SwingConstants.RIGHT); launcherOptionsLabel.setHorizontalTextPosition(SwingConstants.LEADING); launcherOptionsLabel.setAlignmentX(RIGHT_ALIGNMENT); launcherOptionsLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); launcherOptionsLabel.setBorder(BorderFactory.createEmptyBorder()); launcherOptionsLabel.setContentAreaFilled(false); launcherOptionsLabel.setFocusPainted(false); launcherOptionsLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openLauncherOptions(); } }); rightHeaderPanel.add(launcherOptionsLabel); header.add(rightHeaderPanel); ///////////////////////////////////////////////////////////// // CENTRAL AREA ///////////////////////////////////////////////////////////// centralPanel = new TintablePanel(); centralPanel.setBackground(COLOR_CHARCOAL); centralPanel.setForeground(COLOR_WHITE_TEXT); centralPanel.setTintColor(COLOR_CENTRAL_BACK); this.add(centralPanel, BorderLayout.CENTER); centralPanel.setLayout(new BorderLayout()); modpackPanel = new ModpackInfoPanel(resources, iconRepo, logoRepo, backgroundRepo, avatarRepo, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openModpackOptions((ModpackModel) e.getSource()); } }, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { refreshModpackOptions((ModpackModel) e.getSource()); } }); modpackSelector.setInfoPanel(modpackPanel); playButton = modpackPanel.getPlayButton(); playButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof ModpackModel) { setupPlayButtonText((ModpackModel) e.getSource(), userModel.getCurrentUser()); } else if (installer.isCurrentlyRunning()) { installer.cancel(); setupPlayButtonText(modpackSelector.getSelectedPack(), userModel.getCurrentUser()); } else { launchModpack(); } } }); modpackPanel.getDeleteButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(LauncherFrame.this, resources.getString("modpackoptions.delete.confirmtext"), resources.getString("modpackoptions.delete.confirmtitle"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { modpackSelector.getSelectedPack().delete(); modpackSelector.forceRefresh(); } } }); infoSwap = new JPanel(); infoLayout = new CardLayout(); infoSwap.setLayout(infoLayout); infoSwap.setOpaque(false); newsInfoPanel = new NewsInfoPanel(resources, avatarRepo); infoSwap.add(discoverInfoPanel, "discover"); JPanel newsHost = new JPanel(); infoSwap.add(newsHost, "news"); JPanel modpackHost = new JPanel(); infoSwap.add(modpackHost, "modpacks"); centralPanel.add(infoSwap, BorderLayout.CENTER); newsSelector = new NewsSelector(resources, newsInfoPanel, platformApi, avatarRepo, newsCircle, settings); newsHost.setLayout(new BorderLayout()); newsHost.add(newsInfoPanel, BorderLayout.CENTER); newsHost.add(newsSelector, BorderLayout.WEST); modpackHost.setLayout(new BorderLayout()); modpackHost.add(modpackPanel, BorderLayout.CENTER); modpackHost.add(modpackSelector, BorderLayout.WEST); footer = new TintablePanel(); footer.setTintColor(COLOR_CENTRAL_BACK); footer.setBackground(COLOR_FOOTER); footer.setLayout(new BoxLayout(footer, BoxLayout.LINE_AXIS)); footer.setForeground(COLOR_WHITE_TEXT); footer.setBorder(BorderFactory.createEmptyBorder(3, 6, 3, 12)); userWidget = new UserWidget(resources, skinRepository); userWidget.setMaximumSize(userWidget.getPreferredSize()); footer.add(userWidget); JLabel dashText = new JLabel("| "); dashText.setForeground(LauncherFrame.COLOR_WHITE_TEXT); dashText.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 15)); footer.add(dashText); JButton logout = new JButton(resources.getString("launcher.user.logout")); logout.setBorder(BorderFactory.createEmptyBorder()); logout.setContentAreaFilled(false); logout.setFocusable(false); logout.setForeground(LauncherFrame.COLOR_WHITE_TEXT); logout.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); logout.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 15)); logout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logout(); } }); footer.add(logout); installProgress = new ProgressBar(); installProgress.setForeground(Color.white); installProgress.setBackground(LauncherFrame.COLOR_GREEN); installProgress.setBorder(BorderFactory.createEmptyBorder(5, 45, 4, 45)); installProgress.setIcon(resources.getIcon("download_icon.png")); installProgress.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 12)); installProgress.setVisible(false); footer.add(installProgress); installProgressPlaceholder = Box.createHorizontalGlue(); footer.add(installProgressPlaceholder); JLabel buildCtrl = new JLabel(resources.getString("launcher.build.text", resources.getLauncherBuild(), resources.getString("launcher.build." + settings.getBuildStream()))); buildCtrl.setForeground(COLOR_WHITE_TEXT); buildCtrl.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14)); buildCtrl.setHorizontalTextPosition(SwingConstants.RIGHT); buildCtrl.setHorizontalAlignment(SwingConstants.RIGHT); footer.add(buildCtrl); this.add(footer, BorderLayout.PAGE_END); }
From source file:op.care.nursingprocess.PnlNursingProcess.java
private JPanel createNPPanel(final NursingProcess np) { /***/*from w w w . ja v a 2s .c om*/ * _ ____ ____ _ _ _ _ ____ * ___ _ __ ___ __ _| |_ ___ / ___| _ \| || | | \ | | _ \ * / __| '__/ _ \/ _` | __/ _ \ | | |_) | || |_ | \| | |_) | * | (__| | | __/ (_| | || __/ |___| __/|__ _| | |\ | __/ * \___|_| \___|\__,_|\__\___|\____|_| |_| |_| \_|_| * */ if (!contenPanelMap.containsKey(np)) { String title = "<html><table border=\"0\">"; if (!np.getCommontags().isEmpty()) { title += "<tr>" + " <td colspan=\"2\">" + CommontagsTools.getAsHTML(np.getCommontags(), SYSConst.html_16x16_tagPurple_internal) + "</td>" + " </tr>"; } title += "<tr valign=\"top\">" + "<td width=\"280\" align=\"left\">" + np.getPITAsHTML() + "</td>" + "<td width=\"500\" align=\"left\">" + (np.isClosed() ? "<s>" : "") + np.getContentAsHTML() + (np.isClosed() ? "</s>" : "") + "</td></tr>"; title += "</table>" + "</html>"; DefaultCPTitle cptitle = new DefaultCPTitle(title, null); cptitle.getButton().setVerticalTextPosition(SwingConstants.TOP); if (!np.getAttachedFilesConnections().isEmpty()) { /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = new JButton(Integer.toString(np.getAttachedFilesConnections().size()), SYSConst.icon22greenStar); btnFiles.setToolTipText(SYSTools.xx("misc.btnfiles.tooltip")); btnFiles.setForeground(Color.BLUE); btnFiles.setHorizontalTextPosition(SwingUtilities.CENTER); btnFiles.setFont(SYSConst.ARIAL18BOLD); btnFiles.setPressedIcon(SYSConst.icon22Pressed); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.setAlignmentY(Component.TOP_ALIGNMENT); btnFiles.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnFiles.setContentAreaFilled(false); btnFiles.setBorder(null); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { Closure fileHandleClosure = np.isClosed() ? null : new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final NursingProcess myNP = em.find(NursingProcess.class, np.getID()); em.close(); // Refresh Display valuecache.get(np.getCategory()).remove(np); contenPanelMap.remove(np); valuecache.get(myNP.getCategory()).add(myNP); Collections.sort(valuecache.get(myNP.getCategory())); createCP4(myNP.getCategory()); buildPanel(); } }; new DlgFiles(np, fileHandleClosure); } }); btnFiles.setEnabled(OPDE.isFTPworking()); cptitle.getRight().add(btnFiles); } if (!np.getAttachedQProcessConnections().isEmpty()) { /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = new JButton(Integer.toString(np.getAttachedQProcessConnections().size()), SYSConst.icon22redStar); btnProcess.setToolTipText(SYSTools.xx("misc.btnprocess.tooltip")); btnProcess.setForeground(Color.YELLOW); btnProcess.setHorizontalTextPosition(SwingUtilities.CENTER); btnProcess.setFont(SYSConst.ARIAL18BOLD); btnProcess.setPressedIcon(SYSConst.icon22Pressed); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.setAlignmentY(Component.TOP_ALIGNMENT); btnProcess.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnProcess.setContentAreaFilled(false); btnProcess.setBorder(null); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(np, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); final NursingProcess myNP = em.merge(np); em.lock(myNP, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSNP2PROCESS> attached = new ArrayList<SYSNP2PROCESS>( myNP.getAttachedQProcessConnections()); for (SYSNP2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections() .remove(linkObject); linkObject.getNursingProcess().getAttachedQProcessConnections() .remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + myNP.getTitle() + " ID: " + myNP.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { java.util.List<QProcessElement> listElements = qProcess.getElements(); if (!listElements.contains(myNP)) { QProcess myQProcess = em.merge(qProcess); SYSNP2PROCESS myLinkObject = em .merge(new SYSNP2PROCESS(myQProcess, myNP)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + myNP.getTitle() + " ID: " + myNP.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedNursingProcessesConnections().add(myLinkObject); myNP.getAttachedQProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); // Refresh Display valuecache.get(np.getCategory()).remove(np); contenPanelMap.remove(np); valuecache.get(myNP.getCategory()).add(myNP); Collections.sort(valuecache.get(myNP.getCategory())); createCP4(myNP.getCategory()); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } else { reloadDisplay(); } } catch (RollbackException ole) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); } }); btnProcess.setEnabled(OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)); cptitle.getRight().add(btnProcess); } if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.PRINT, internalClassID)) { /*** * _ _ ____ _ _ * | |__ | |_ _ __ | _ \ _ __(_)_ __ | |_ * | '_ \| __| '_ \| |_) | '__| | '_ \| __| * | |_) | |_| | | | __/| | | | | | | |_ * |_.__/ \__|_| |_|_| |_| |_|_| |_|\__| * */ JButton btnPrint = new JButton(SYSConst.icon22print2); btnPrint.setContentAreaFilled(false); btnPrint.setBorder(null); btnPrint.setPressedIcon(SYSConst.icon22print2Pressed); btnPrint.setAlignmentX(Component.RIGHT_ALIGNMENT); btnPrint.setAlignmentY(Component.TOP_ALIGNMENT); btnPrint.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { SYSFilesTools.print(NursingProcessTools.getAsHTML(np, true, true, true, true), true); } }); cptitle.getRight().add(btnPrint); // cptitle.getTitleButton().setVerticalTextPosition(SwingConstants.TOP); } /*** * __ __ * | \/ | ___ _ __ _ _ * | |\/| |/ _ \ '_ \| | | | * | | | | __/ | | | |_| | * |_| |_|\___|_| |_|\__,_| * */ final JButton btnMenu = new JButton(SYSConst.icon22menu); btnMenu.setPressedIcon(SYSConst.icon22Pressed); btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMenu.setAlignmentY(Component.TOP_ALIGNMENT); btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMenu.setContentAreaFilled(false); btnMenu.setBorder(null); btnMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnMenu); popup.removeExcludedComponent(btnMenu); JPanel pnl = getMenu(np); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnMenu.setEnabled(!np.isClosed()); cptitle.getButton().setIcon(getIcon(np)); cptitle.getRight().add(btnMenu); cptitle.getMain().setBackground(getColor(np.getCategory())[SYSConst.light2]); cptitle.getMain().setOpaque(true); contenPanelMap.put(np, cptitle.getMain()); } return contenPanelMap.get(np); }
From source file:op.care.prescription.PnlPrescription.java
private CollapsiblePane createCP4(final Prescription prescription) { /***/* w w w . j a v a 2 s . co m*/ * _ ____ ____ _ _ ______ _ _ _ __ * ___ _ __ ___ __ _| |_ ___ / ___| _ \| || | / / _ \ _ __ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __\ \ * / __| '__/ _ \/ _` | __/ _ \ | | |_) | || |_| || |_) | '__/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \| | * | (__| | | __/ (_| | || __/ |___| __/|__ _| || __/| | | __/\__ \ (__| | | | |_) | |_| | (_) | | | | | * \___|_| \___|\__,_|\__\___|\____|_| |_| | ||_| |_| \___||___/\___|_| |_| .__/ \__|_|\___/|_| |_| | * \_\ |_| /_/ */ final String key = prescription.getID() + ".xprescription"; if (!cpMap.containsKey(key)) { cpMap.put(key, new CollapsiblePane()); try { cpMap.get(key).setCollapsed(true); } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } final CollapsiblePane cpPres = cpMap.get(key); String title = "<html><table border=\"0\">" + "<tr valign=\"top\">" + "<td width=\"280\" align=\"left\">" + prescription.getPITAsHTML() + "</td>" + "<td width=\"380\" align=\"left\">" + "<font size=+1>" + PrescriptionTools.getShortDescription(prescription) + "</font>" + PrescriptionTools.getDoseAsHTML(prescription) + PrescriptionTools.getInventoryInformationAsHTML(prescription) + "</td>" + "<td width=\"200\" align=\"left\">" + PrescriptionTools.getOriginalPrescription(prescription) + PrescriptionTools.getRemark(prescription) + "</td>"; if (!prescription.getCommontags().isEmpty()) { title += "<tr>" + " <td colspan=\"3\">" + CommontagsTools.getAsHTML(prescription.getCommontags(), SYSConst.html_16x16_tagPurple_internal) + "</td>" + " </tr>"; } if (PrescriptionTools.isAnnotationNecessary(prescription)) { title += "<tr>" + " <td colspan=\"3\">" + PrescriptionTools.getAnnontationsAsHTML(prescription) + "</td>" + " </tr>"; } title += "</table>" + "</html>"; DefaultCPTitle cptitle = new DefaultCPTitle(title, null); cpPres.setCollapsible(false); cptitle.getButton().setIcon(getIcon(prescription)); cpPres.setTitleLabelComponent(cptitle.getMain()); cpPres.setSlidingDirection(SwingConstants.SOUTH); if (!prescription.getAttachedFilesConnections().isEmpty()) { /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = new JButton( Integer.toString(prescription.getAttachedFilesConnections().size()), SYSConst.icon22greenStar); btnFiles.setToolTipText(SYSTools.xx("misc.btnfiles.tooltip")); btnFiles.setForeground(Color.BLUE); btnFiles.setHorizontalTextPosition(SwingUtilities.CENTER); btnFiles.setFont(SYSConst.ARIAL18BOLD); btnFiles.setPressedIcon(SYSConst.icon22Pressed); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.setAlignmentY(Component.TOP_ALIGNMENT); btnFiles.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnFiles.setContentAreaFilled(false); btnFiles.setBorder(null); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { // checked for acls Closure fileHandleClosure = OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID) ? null : new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final Prescription myPrescription = em.find(Prescription.class, prescription.getID()); em.close(); lstPrescriptions.remove(prescription); lstPrescriptions.add(myPrescription); Collections.sort(lstPrescriptions); final CollapsiblePane myCP = createCP4(myPrescription); buildPanel(); GUITools.flashBackground(myCP, Color.YELLOW, 2); } }; new DlgFiles(prescription, fileHandleClosure); } }); btnFiles.setEnabled(OPDE.isFTPworking()); cptitle.getRight().add(btnFiles); } if (!prescription.getAttachedProcessConnections().isEmpty()) { /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = new JButton( Integer.toString(prescription.getAttachedProcessConnections().size()), SYSConst.icon22redStar); btnProcess.setToolTipText(SYSTools.xx("misc.btnprocess.tooltip")); btnProcess.setForeground(Color.YELLOW); btnProcess.setHorizontalTextPosition(SwingUtilities.CENTER); btnProcess.setFont(SYSConst.ARIAL18BOLD); btnProcess.setPressedIcon(SYSConst.icon22Pressed); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.setAlignmentY(Component.TOP_ALIGNMENT); btnProcess.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnProcess.setContentAreaFilled(false); btnProcess.setBorder(null); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(prescription, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); Prescription myPrescription = em.merge(prescription); em.lock(myPrescription, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSPRE2PROCESS> attached = new ArrayList<SYSPRE2PROCESS>( prescription.getAttachedProcessConnections()); for (SYSPRE2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections().remove(linkObject); linkObject.getPrescription().getAttachedProcessConnections() .remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + myPrescription.getTitle() + " ID: " + myPrescription.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { List<QProcessElement> listElements = qProcess.getElements(); if (!listElements.contains(myPrescription)) { QProcess myQProcess = em.merge(qProcess); SYSPRE2PROCESS myLinkObject = em .merge(new SYSPRE2PROCESS(myQProcess, myPrescription)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + myPrescription.getTitle() + " ID: " + myPrescription.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedPrescriptionConnections().add(myLinkObject); myPrescription.getAttachedProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); lstPrescriptions.remove(prescription); lstPrescriptions.add(myPrescription); Collections.sort(lstPrescriptions); final CollapsiblePane myCP = createCP4(myPrescription); buildPanel(); GUITools.flashBackground(myCP, Color.YELLOW, 2); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (RollbackException ole) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); } }); // checked for acls btnProcess.setEnabled(OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)); cptitle.getRight().add(btnProcess); } /*** * __ __ * | \/ | ___ _ __ _ _ * | |\/| |/ _ \ '_ \| | | | * | | | | __/ | | | |_| | * |_| |_|\___|_| |_|\__,_| * */ final JButton btnMenu = new JButton(SYSConst.icon22menu); btnMenu.setPressedIcon(SYSConst.icon22Pressed); btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMenu.setAlignmentY(Component.TOP_ALIGNMENT); btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMenu.setContentAreaFilled(false); btnMenu.setBorder(null); btnMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnMenu); popup.removeExcludedComponent(btnMenu); JPanel pnl = getMenu(prescription); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); cptitle.getRight().add(btnMenu); cpPres.setHorizontalAlignment(SwingConstants.LEADING); cpPres.setOpaque(false); return cpPres; }
From source file:op.care.reports.PnlReport.java
private JPanel createContentPanel4Day(LocalDate day) { // OPDE.getDisplayManager().setProgressBarMessage(new DisplayMessage("misc.msg.wait", progress, progressMax)); // progress++; final String key = DateFormat.getDateInstance().format(day.toDate()); synchronized (contentmap) { if (contentmap.containsKey(key)) { return contentmap.get(key); }//from ww w .j ava 2s . c om } final JPanel dayPanel = new JPanel(new VerticalLayout()); dayPanel.setOpaque(false); synchronized (valuecache) { if (!valuecache.containsKey(key)) { valuecache.put(key, NReportTools.getNReports4Day(resident, day)); } int i = 0; // for zebra pattern for (final NReport nreport : valuecache.get(key)) { if (tbShowReplaced.isSelected() || !nreport.isObsolete()) { String title = SYSTools.toHTMLForScreen(SYSConst.html_table(SYSConst .html_table_tr("<td width=\"800\" align=\"left\">" + "<b><p>" + (nreport.isObsolete() ? SYSConst.html_16x16_Eraser_internal : "") + (nreport.isReplacement() ? SYSConst.html_16x16_Edited_internal : "") + DateFormat.getTimeInstance(DateFormat.SHORT).format(nreport.getPit()) + " " + SYSTools.xx("misc.msg.Time.short") + ", " + nreport.getMinutes() + " " + SYSTools.xx("misc.msg.Minute(s)") + ", " + nreport.getUser().getFullname() + (nreport.getCommontags().isEmpty() ? "" : " " + CommontagsTools.getAsHTML(nreport.getCommontags(), SYSConst.html_16x16_tagPurple_internal)) + "</p></b></td>") + SYSConst.html_table_tr("<td width=\"800\" align=\"left\">" + SYSTools.replace(nreport.getText(), "\n", "<br/>", false) + "</td>"), "0")); final DefaultCPTitle pnlSingle = new DefaultCPTitle(SYSTools.toHTMLForScreen(title), null); pnlSingle.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { GUITools.showPopup(GUITools.getHTMLPopup(pnlSingle.getButton(), NReportTools.getInfoAsHTML(nreport)), SwingConstants.NORTH); } }); if (!nreport.getAttachedFilesConnections().isEmpty()) { /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = new JButton( Integer.toString(nreport.getAttachedFilesConnections().size()), SYSConst.icon22greenStar); btnFiles.setToolTipText(SYSTools.xx("misc.btnfiles.tooltip")); btnFiles.setForeground(Color.BLUE); btnFiles.setHorizontalTextPosition(SwingUtilities.CENTER); btnFiles.setFont(SYSConst.ARIAL18BOLD); btnFiles.setPressedIcon(SYSConst.icon22Pressed); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.setAlignmentY(Component.TOP_ALIGNMENT); btnFiles.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnFiles.setContentAreaFilled(false); btnFiles.setBorder(null); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { Closure fileHandleClosure = OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID) ? null : new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final NReport myReport = em.find(NReport.class, nreport.getID()); em.close(); final String keyNewDay = DateFormat.getDateInstance() .format(myReport.getPit()); synchronized (contentmap) { contentmap.remove(keyNewDay); } synchronized (linemap) { linemap.remove(nreport); } synchronized (valuecache) { valuecache.get(keyNewDay).remove(nreport); valuecache.get(keyNewDay).add(myReport); Collections.sort(valuecache.get(keyNewDay)); } createCP4Day(new LocalDate(myReport.getPit())); buildPanel(); GUITools.flashBackground(linemap.get(myReport), Color.YELLOW, 2); } }; new DlgFiles(nreport, fileHandleClosure); } }); btnFiles.setEnabled(OPDE.isFTPworking()); pnlSingle.getRight().add(btnFiles); } if (!nreport.getAttachedQProcessConnections().isEmpty()) { /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = new JButton( Integer.toString(nreport.getAttachedQProcessConnections().size()), SYSConst.icon22redStar); btnProcess.setToolTipText(SYSTools.xx("misc.btnprocess.tooltip")); btnProcess.setForeground(Color.YELLOW); btnProcess.setHorizontalTextPosition(SwingUtilities.CENTER); btnProcess.setFont(SYSConst.ARIAL18BOLD); btnProcess.setPressedIcon(SYSConst.icon22Pressed); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.setAlignmentY(Component.TOP_ALIGNMENT); btnProcess.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnProcess.setContentAreaFilled(false); btnProcess.setBorder(null); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(nreport, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); NReport myReport = em.merge(nreport); em.lock(myReport, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSNR2PROCESS> attached = new ArrayList<SYSNR2PROCESS>( myReport.getAttachedQProcessConnections()); for (SYSNR2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections() .remove(linkObject); linkObject.getNReport().getAttachedQProcessConnections() .remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + nreport.getTitle() + " ID: " + nreport.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { java.util.List<QProcessElement> listElements = qProcess .getElements(); if (!listElements.contains(myReport)) { QProcess myQProcess = em.merge(qProcess); SYSNR2PROCESS myLinkObject = em .merge(new SYSNR2PROCESS(myQProcess, myReport)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + nreport.getTitle() + " ID: " + nreport.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedNReportConnections().add(myLinkObject); myReport.getAttachedQProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); final String keyNewDay = DateFormat.getDateInstance() .format(myReport.getPit()); synchronized (contentmap) { contentmap.remove(keyNewDay); } synchronized (linemap) { linemap.remove(nreport); } synchronized (valuecache) { valuecache.get(keyNewDay).remove(nreport); valuecache.get(keyNewDay).add(myReport); Collections.sort(valuecache.get(keyNewDay)); } createCP4Day(new LocalDate(myReport.getPit())); buildPanel(); GUITools.flashBackground(linemap.get(myReport), Color.YELLOW, 2); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } else { reloadDisplay(true); } } catch (RollbackException ole) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); } }); btnProcess.setEnabled( OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)); pnlSingle.getRight().add(btnProcess); } /*** * __ __ * | \/ | ___ _ __ _ _ * | |\/| |/ _ \ '_ \| | | | * | | | | __/ | | | |_| | * |_| |_|\___|_| |_|\__,_| * */ final JButton btnMenu = new JButton(SYSConst.icon22menu); btnMenu.setPressedIcon(SYSConst.icon22Pressed); btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMenu.setAlignmentY(Component.TOP_ALIGNMENT); btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMenu.setContentAreaFilled(false); btnMenu.setBorder(null); btnMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane() .setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnMenu); popup.removeExcludedComponent(btnMenu); JPanel pnl = getMenu(nreport); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnMenu.setEnabled(!nreport.isObsolete()); pnlSingle.getRight().add(btnMenu); JPanel zebra = new JPanel(); zebra.setLayout(new BoxLayout(zebra, BoxLayout.LINE_AXIS)); zebra.setOpaque(true); if (i % 2 == 0) { zebra.setBackground(SYSConst.orange1[SYSConst.light2]); } else { zebra.setBackground(Color.WHITE); } zebra.add(pnlSingle.getMain()); i++; dayPanel.add(zebra); linemap.put(nreport, pnlSingle.getMain()); } } } synchronized (contentmap) { contentmap.put(key, dayPanel); } return dayPanel; }
From source file:op.care.values.PnlValues.java
private JPanel createContentPanel4Year(final ResValueTypes vtype, final int year) { final String keyYears = vtype.getID() + ".xtypes." + Integer.toString(year) + ".year"; java.util.List<ResValue> myValues; synchronized (mapType2Values) { if (!mapType2Values.containsKey(keyYears)) { mapType2Values.put(keyYears, ResValueTools.getResValues(resident, vtype, year)); }/* ww w .j a va 2 s.c om*/ if (mapType2Values.get(keyYears).isEmpty()) { JLabel lbl = new JLabel(SYSTools.xx("misc.msg.novalue")); JPanel pnl = new JPanel(); pnl.add(lbl); return pnl; } myValues = mapType2Values.get(keyYears); } JPanel pnlYear = new JPanel(new VerticalLayout()); pnlYear.setOpaque(false); for (final ResValue resValue : myValues) { String title = "<html><table border=\"0\">" + "<tr>" + "<td width=\"200\" align=\"left\">" + DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT).format(resValue.getPit()) + " [" + resValue.getID() + "]</td>" + "<td width=\"340\" align=\"left\">" + ResValueTools.getValueAsHTML(resValue) + "</td>" + "<td width=\"200\" align=\"left\">" + resValue.getUser().getFullname() + "</td>" + "</tr>" + "</table>" + "</html>"; final DefaultCPTitle pnlTitle = new DefaultCPTitle(title, null); pnlTitle.getMain().setBackground(GUITools.blend(vtype.getColor(), Color.WHITE, 0.1f)); pnlTitle.getMain().setOpaque(true); if (resValue.isObsolete()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22eraser)); } if (resValue.isReplacement()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22edited)); } if (!resValue.getText().trim().isEmpty()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22info)); } if (pnlTitle.getAdditionalIconPanel().getComponentCount() > 0) { pnlTitle.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { GUITools.showPopup( GUITools.getHTMLPopup(pnlTitle.getButton(), ResValueTools.getInfoAsHTML(resValue)), SwingConstants.NORTH); } }); } if (!resValue.getAttachedFilesConnections().isEmpty()) { /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = new JButton( Integer.toString(resValue.getAttachedFilesConnections().size()), SYSConst.icon22greenStar); btnFiles.setToolTipText(SYSTools.xx("misc.btnfiles.tooltip")); btnFiles.setForeground(Color.BLUE); btnFiles.setHorizontalTextPosition(SwingUtilities.CENTER); btnFiles.setFont(SYSConst.ARIAL18BOLD); btnFiles.setPressedIcon(SYSConst.icon22Pressed); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.setAlignmentY(Component.TOP_ALIGNMENT); btnFiles.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnFiles.setContentAreaFilled(false); btnFiles.setBorder(null); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgFiles(resValue, new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final ResValue myValue = em.find(ResValue.class, resValue.getID()); em.close(); synchronized (mapType2Values) { mapType2Values.get(keyYears).remove(resValue); mapType2Values.get(keyYears).add(myValue); Collections.sort(mapType2Values.get(keyYears)); } createCP4Year(vtype, year); buildPanel(); } }); } }); btnFiles.setEnabled(OPDE.isFTPworking()); pnlTitle.getRight().add(btnFiles); } if (!resValue.getAttachedProcessConnections().isEmpty()) { /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = new JButton( Integer.toString(resValue.getAttachedProcessConnections().size()), SYSConst.icon22redStar); btnProcess.setToolTipText(SYSTools.xx("misc.btnprocess.tooltip")); btnProcess.setForeground(Color.YELLOW); btnProcess.setHorizontalTextPosition(SwingUtilities.CENTER); btnProcess.setFont(SYSConst.ARIAL18BOLD); btnProcess.setPressedIcon(SYSConst.icon22Pressed); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.setAlignmentY(Component.TOP_ALIGNMENT); btnProcess.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnProcess.setContentAreaFilled(false); btnProcess.setBorder(null); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(resValue, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); ResValue myValue = em.merge(resValue); em.lock(myValue, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSVAL2PROCESS> attached = new ArrayList<SYSVAL2PROCESS>( resValue.getAttachedProcessConnections()); for (SYSVAL2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections() .remove(linkObject); linkObject.getResValue().getAttachedProcessConnections() .remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { java.util.List<QProcessElement> listElements = qProcess.getElements(); if (!listElements.contains(myValue)) { QProcess myQProcess = em.merge(qProcess); SYSVAL2PROCESS myLinkObject = em .merge(new SYSVAL2PROCESS(myQProcess, myValue)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedResValueConnections().add(myLinkObject); myValue.getAttachedProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); synchronized (mapType2Values) { mapType2Values.get(keyYears).remove(resValue); mapType2Values.get(keyYears).add(myValue); Collections.sort(mapType2Values.get(keyYears)); } createCP4Year(vtype, year); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (RollbackException ole) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); } }); btnProcess.setEnabled(OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)); pnlTitle.getRight().add(btnProcess); } /*** * __ __ * | \/ | ___ _ __ _ _ * | |\/| |/ _ \ '_ \| | | | * | | | | __/ | | | |_| | * |_| |_|\___|_| |_|\__,_| * */ final JButton btnMenu = new JButton(SYSConst.icon22menu); btnMenu.setPressedIcon(SYSConst.icon22Pressed); btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMenu.setAlignmentY(Component.TOP_ALIGNMENT); btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMenu.setContentAreaFilled(false); btnMenu.setBorder(null); btnMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnMenu); popup.removeExcludedComponent(btnMenu); JPanel pnl = getMenu(resValue); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnMenu.setEnabled(!resValue.isObsolete()); pnlTitle.getRight().add(btnMenu); pnlYear.add(pnlTitle.getMain()); synchronized (linemap) { linemap.put(resValue, pnlTitle.getMain()); } } return pnlYear; }
From source file:org.apache.jmeter.visualizers.StatGraphVisualizer.java
private JButton createColorBarButton(BarGraph barGraph, int index) { // Button//from w ww.jav a 2s . com JButton colorBtn = new JButton(); colorBtn.setName(String.valueOf(index)); colorBtn.setFont(FONT_SMALL); colorBtn.addActionListener(this); colorBtn.setBackground(barGraph.getBackColor()); return colorBtn; }