Search in sources :

Example 31 with JInternalFrame

use of javax.swing.JInternalFrame in project JMRI by JMRI.

the class ThrottleFrame method loadThrottle.

public void loadThrottle(String sfile) {
    if (sfile == null) {
        JFileChooser fileChooser = jmri.jmrit.XmlFile.userFileChooser(Bundle.getMessage("PromptXmlFileTypes"), "xml");
        fileChooser.setCurrentDirectory(new File(getDefaultThrottleFolder()));
        fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
        java.io.File file = LoadXmlConfigAction.getFile(fileChooser);
        if (file == null) {
            return;
        }
        sfile = file.getAbsolutePath();
        if (sfile == null) {
            return;
        }
    }
    boolean switchAfter = false;
    if (!isEditMode) {
        switchMode();
        switchAfter = true;
    }
    try {
        XmlFile xf = new XmlFile() {
        };
        // odd syntax is due to XmlFile being abstract
        File f = new File(sfile);
        Element root = xf.rootFromFile(f);
        Element conf = root.getChild("ThrottleFrame");
        // File looks ok
        setLastUsedSaveFile(sfile);
        // close all existing Jynstruments
        Component[] cmps = getComponents();
        for (int i = 0; i < cmps.length; i++) {
            try {
                if (cmps[i] instanceof JInternalFrame) {
                    JInternalFrame jyf = (JInternalFrame) cmps[i];
                    Component[] cmps2 = jyf.getContentPane().getComponents();
                    for (int j = 0; j < cmps2.length; j++) {
                        if (cmps2[j] instanceof Jynstrument) {
                            ((Jynstrument) cmps2[j]).exit();
                            jyf.dispose();
                        }
                    }
                }
            } catch (Exception ex) {
                log.debug("Got exception (no panic) " + ex);
            }
        }
        // and finally load all preferences
        setXml(conf);
    } catch (Exception ex) {
        if (log.isDebugEnabled()) {
            log.debug("Loading throttle exception: " + ex.getMessage());
        }
    }
    //     checkPosition();
    if (switchAfter) {
        switchMode();
    }
    return;
}
Also used : Jynstrument(jmri.jmrit.jython.Jynstrument) XmlFile(jmri.jmrit.XmlFile) Element(org.jdom2.Element) File(java.io.File) Point(java.awt.Point) JFileChooser(javax.swing.JFileChooser) JComponent(javax.swing.JComponent) Component(java.awt.Component) File(java.io.File) XmlFile(jmri.jmrit.XmlFile) JInternalFrame(javax.swing.JInternalFrame)

Example 32 with JInternalFrame

use of javax.swing.JInternalFrame in project sic by belluccifranco.

the class PrincipalGUI method mnuItm_ProductosActionPerformed.

//GEN-LAST:event_mnuItm_TransportistasActionPerformed
private void mnuItm_ProductosActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_mnuItm_ProductosActionPerformed
    JInternalFrame gui = Utilidades.estaEnDesktop(getDesktopPane(), ProductosGUI.class);
    if (gui == null) {
        ProductosGUI productos = new ProductosGUI();
        productos.setLocation(getDesktopPane().getWidth() / 2 - productos.getWidth() / 2, getDesktopPane().getHeight() / 2 - productos.getHeight() / 2);
        getDesktopPane().add(productos);
        productos.setVisible(true);
    } else {
        //selecciona y trae al frente el internalframe
        try {
            gui.setSelected(true);
        } catch (PropertyVetoException ex) {
            String msjError = "No se pudo seleccionar la ventana requerida.";
            LOGGER.error(msjError + " - " + ex.getMessage());
            JOptionPane.showInternalMessageDialog(this.getDesktopPane(), msjError, "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) JInternalFrame(javax.swing.JInternalFrame)

Example 33 with JInternalFrame

use of javax.swing.JInternalFrame in project sic by belluccifranco.

the class PrincipalGUI method mnuItm_FacturasCompraActionPerformed.

//GEN-LAST:event_mnuItm_ProveedoresActionPerformed
private void mnuItm_FacturasCompraActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_mnuItm_FacturasCompraActionPerformed
    JInternalFrame gui = Utilidades.estaEnDesktop(getDesktopPane(), FacturasCompraGUI.class);
    if (gui == null) {
        gui = new FacturasCompraGUI();
        gui.setLocation(getDesktopPane().getWidth() / 2 - gui.getWidth() / 2, getDesktopPane().getHeight() / 2 - gui.getHeight() / 2);
        getDesktopPane().add(gui);
        gui.setVisible(true);
    } else {
        //selecciona y trae al frente el internalframe
        try {
            gui.setSelected(true);
        } catch (PropertyVetoException ex) {
            String msjError = "No se pudo seleccionar la ventana requerida.";
            LOGGER.error(msjError + " - " + ex.getMessage());
            JOptionPane.showInternalMessageDialog(this.getDesktopPane(), msjError, "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) JInternalFrame(javax.swing.JInternalFrame)

Example 34 with JInternalFrame

use of javax.swing.JInternalFrame in project sic by belluccifranco.

the class PrincipalGUI method mnuItm_PedidosActionPerformed.

//GEN-LAST:event_mnuItm_ConfiguracionActionPerformed
private void mnuItm_PedidosActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_mnuItm_PedidosActionPerformed
    JInternalFrame gui = Utilidades.estaEnDesktop(getDesktopPane(), PedidosGUI.class);
    if (gui == null) {
        gui = new PedidosGUI();
        gui.setLocation(getDesktopPane().getWidth() / 2 - gui.getWidth() / 2, getDesktopPane().getHeight() / 2 - gui.getHeight() / 2);
        getDesktopPane().add(gui);
        gui.setVisible(true);
    } else {
        //selecciona y trae al frente el internalframe
        try {
            gui.setSelected(true);
        } catch (PropertyVetoException ex) {
            String msjError = "No se pudo seleccionar la ventana requerida.";
            LOGGER.error(msjError + " - " + ex.getMessage());
            JOptionPane.showInternalMessageDialog(this.getDesktopPane(), msjError, "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) JInternalFrame(javax.swing.JInternalFrame)

Example 35 with JInternalFrame

use of javax.swing.JInternalFrame in project sic by belluccifranco.

the class PrincipalGUI method mnuItm_TransportistasActionPerformed.

//GEN-LAST:event_mnuItm_FacturasCompraActionPerformed
private void mnuItm_TransportistasActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_mnuItm_TransportistasActionPerformed
    JInternalFrame gui = Utilidades.estaEnDesktop(getDesktopPane(), TransportistasGUI.class);
    if (gui == null) {
        gui = new TransportistasGUI();
        gui.setLocation(getDesktopPane().getWidth() / 2 - gui.getWidth() / 2, getDesktopPane().getHeight() / 2 - gui.getHeight() / 2);
        getDesktopPane().add(gui);
        gui.setVisible(true);
    } else {
        //selecciona y trae al frente el internalframe
        try {
            gui.setSelected(true);
        } catch (PropertyVetoException ex) {
            String msjError = "No se pudo seleccionar la ventana requerida.";
            LOGGER.error(msjError + " - " + ex.getMessage());
            JOptionPane.showInternalMessageDialog(this.getDesktopPane(), msjError, "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) JInternalFrame(javax.swing.JInternalFrame)

Aggregations

JInternalFrame (javax.swing.JInternalFrame)36 Point (java.awt.Point)12 PropertyVetoException (java.beans.PropertyVetoException)12 Dimension (java.awt.Dimension)9 Component (java.awt.Component)7 JPanel (javax.swing.JPanel)7 JScrollPane (javax.swing.JScrollPane)7 JTable (javax.swing.JTable)7 BorderLayout (java.awt.BorderLayout)6 JButton (javax.swing.JButton)6 JLabel (javax.swing.JLabel)6 JComponent (javax.swing.JComponent)5 JMenu (javax.swing.JMenu)4 Jynstrument (jmri.jmrit.jython.Jynstrument)4 Container (java.awt.Container)3 JDesktopPane (javax.swing.JDesktopPane)3 JMenuBar (javax.swing.JMenuBar)3 JMenuItem (javax.swing.JMenuItem)3 TableRowSorter (javax.swing.table.TableRowSorter)3 ButtonEditor (jmri.util.table.ButtonEditor)3