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;
}
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);
}
}
}
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);
}
}
}
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);
}
}
}
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);
}
}
}
Aggregations