Search in sources :

Example 1 with JmrixConfigPane

use of jmri.jmrix.JmrixConfigPane in project JMRI by JMRI.

the class JmrixConfigPaneXml method store.

/**
     * Forward to the configurexml class for the specific object type.
     */
@Override
public Element store(Object o) {
    ConnectionConfig oprime = ((JmrixConfigPane) o).getCurrentObject();
    if (oprime == null) {
        return null;
    }
    String adapter = ConfigXmlManager.adapterName(oprime);
    log.debug("forward to " + adapter);
    try {
        XmlAdapter x = (XmlAdapter) Class.forName(adapter).newInstance();
        return x.store(oprime);
    } catch (Exception e) {
        log.error("Exception: " + e);
        e.printStackTrace();
        return null;
    }
}
Also used : JmrixConfigPane(jmri.jmrix.JmrixConfigPane) ConnectionConfig(jmri.jmrix.ConnectionConfig) AbstractXmlAdapter(jmri.configurexml.AbstractXmlAdapter) XmlAdapter(jmri.configurexml.XmlAdapter) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException)

Example 2 with JmrixConfigPane

use of jmri.jmrix.JmrixConfigPane in project JMRI by JMRI.

the class ConnectionsPreferencesPanel method removeTab.

private void removeTab(ActionEvent e, int x) {
    int i;
    i = x;
    if (i != -1) {
        // only prompt if triggered by action event
        if (e != null) {
            int n = JOptionPane.showConfirmDialog(null, MessageFormat.format(rb.getString("MessageDoDelete"), new Object[] { this.getTitleAt(i) }), rb.getString("MessageDeleteConnection"), JOptionPane.YES_NO_OPTION);
            if (n != JOptionPane.YES_OPTION) {
                return;
            }
        }
        JmrixConfigPane configPane = this.configPanes.get(i);
        this.removeChangeListener(addTabListener);
        // was x
        this.remove(i);
        try {
            JmrixConfigPane.dispose(configPane);
        } catch (NullPointerException ex) {
            log.error("Caught Null Pointer Exception while removing connection tab");
        }
        this.configPanes.remove(i);
        if (this.getTabCount() == 1) {
            addConnectionTab();
        }
        if (x != 0) {
            this.setSelectedIndex(x - 1);
        } else {
            this.setSelectedIndex(0);
        }
        this.addChangeListener(addTabListener);
    }
    activeTab();
}
Also used : JmrixConfigPane(jmri.jmrix.JmrixConfigPane)

Aggregations

JmrixConfigPane (jmri.jmrix.JmrixConfigPane)2 UnsupportedLookAndFeelException (javax.swing.UnsupportedLookAndFeelException)1 AbstractXmlAdapter (jmri.configurexml.AbstractXmlAdapter)1 XmlAdapter (jmri.configurexml.XmlAdapter)1 ConnectionConfig (jmri.jmrix.ConnectionConfig)1