Search in sources :

Example 61 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class ThrottlesListPanel method initGUI.

private void initGUI() {
    throttleFrames = new JTable(throttleFramesLM);
    throttleFrames.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    throttleFrames.setRowHeight(ThrottlesTableCellRenderer.height);
    throttleFrames.setTableHeader(null);
    throttleFrames.setDefaultRenderer(Object.class, new ThrottlesTableCellRenderer());
    throttleFrames.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
            int row = throttleFrames.rowAtPoint(e.getPoint());
            throttleFrames.getSelectionModel().setSelectionInterval(row, row);
            ((ThrottleFrame) throttleFramesLM.getValueAt(row, 0)).toFront();
        }

        @Override
        public void mouseEntered(MouseEvent arg0) {
        }

        @Override
        public void mouseExited(MouseEvent arg0) {
        }

        @Override
        public void mousePressed(MouseEvent arg0) {
        }

        @Override
        public void mouseReleased(MouseEvent arg0) {
        }
    });
    JScrollPane scrollPane1 = new JScrollPane(throttleFrames);
    setLayout(new BorderLayout());
    setPreferredSize(new Dimension(320, 200));
    JToolBar throttleToolBar = new JToolBar("Throttles list toolbar");
    JButton jbNew = new JButton();
    jbNew.setIcon(new NamedIcon("resources/icons/throttles/new.png", "resources/icons/throttles/new.png"));
    jbNew.setToolTipText(Bundle.getMessage("ThrottleToolBarNewWindowToolTip"));
    jbNew.setVerticalTextPosition(JButton.BOTTOM);
    jbNew.setHorizontalTextPosition(JButton.CENTER);
    jbNew.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ThrottleFrame tf = ThrottleFrameManager.instance().createThrottleFrame();
            tf.toFront();
        }
    });
    throttleToolBar.add(jbNew);
    throttleToolBar.addSeparator();
    throttleToolBar.add(new StopAllButton());
    throttleToolBar.add(new LargePowerManagerButton());
    add(throttleToolBar, BorderLayout.PAGE_START);
    add(scrollPane1, BorderLayout.CENTER);
    throttleToolBar.addSeparator();
    JButton jbPreferences = new JButton();
    jbPreferences.setIcon(new NamedIcon("resources/icons/throttles/preferences.png", "resources/icons/throttles/Preferences24.png"));
    jbPreferences.setToolTipText(Bundle.getMessage("ThrottleToolBarPreferencesToolTip"));
    jbPreferences.setVerticalTextPosition(JButton.BOTTOM);
    jbPreferences.setHorizontalTextPosition(JButton.CENTER);
    jbPreferences.addActionListener(new ThrottlesPreferencesAction());
    throttleToolBar.add(jbPreferences);
}
Also used : JScrollPane(javax.swing.JScrollPane) NamedIcon(jmri.jmrit.catalog.NamedIcon) MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) JToolBar(javax.swing.JToolBar) MouseListener(java.awt.event.MouseListener) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable)

Example 62 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class ThrottleWindow method initializeToolbar.

private void initializeToolbar() {
    throttleToolBar = new JToolBar("Throttles toolbar");
    jbNew = new JButton();
    //    nouveau.setText(Bundle.getMessage("ThrottleToolBarNew"));
    jbNew.setIcon(new NamedIcon("resources/icons/throttles/add.png", "resources/icons/throttles/add.png"));
    jbNew.setToolTipText(Bundle.getMessage("ThrottleToolBarNewToolTip"));
    jbNew.setVerticalTextPosition(JButton.BOTTOM);
    jbNew.setHorizontalTextPosition(JButton.CENTER);
    jbNew.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            addThrottleFrame();
        }
    });
    throttleToolBar.add(jbNew);
    jbClose = new JButton();
    //     close.setText(Bundle.getMessage("ThrottleToolBarClose"));
    jbClose.setIcon(new NamedIcon("resources/icons/throttles/remove.png", "resources/icons/throttles/remove.png"));
    jbClose.setToolTipText(Bundle.getMessage("ThrottleToolBarCloseToolTip"));
    jbClose.setVerticalTextPosition(JButton.BOTTOM);
    jbClose.setHorizontalTextPosition(JButton.CENTER);
    jbClose.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            removeThrottleFrame();
        }
    });
    throttleToolBar.add(jbClose);
    throttleToolBar.addSeparator();
    jbPreviousRunning = new JButton();
    jbPreviousRunning.setIcon(new NamedIcon("resources/icons/throttles/previous-jump.png", "resources/icons/throttles/previous-jump.png"));
    jbPreviousRunning.setVerticalTextPosition(JButton.BOTTOM);
    jbPreviousRunning.setHorizontalTextPosition(JButton.CENTER);
    jbPreviousRunning.setToolTipText(Bundle.getMessage("ThrottleToolBarPrevRunToolTip"));
    jbPreviousRunning.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            previousRunningThrottleFrame();
        }
    });
    throttleToolBar.add(jbPreviousRunning);
    jbPrevious = new JButton();
    jbPrevious.setIcon(new NamedIcon("resources/icons/throttles/previous.png", "resources/icons/throttles/previous.png"));
    jbPrevious.setVerticalTextPosition(JButton.BOTTOM);
    jbPrevious.setHorizontalTextPosition(JButton.CENTER);
    jbPrevious.setToolTipText(Bundle.getMessage("ThrottleToolBarPrevToolTip"));
    jbPrevious.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            previousThrottleFrame();
        }
    });
    throttleToolBar.add(jbPrevious);
    jbNext = new JButton();
    //    next.setText(Bundle.getMessage("ThrottleToolBarNext"));
    jbNext.setIcon(new NamedIcon("resources/icons/throttles/next.png", "resources/icons/throttles/next.png"));
    jbNext.setToolTipText(Bundle.getMessage("ThrottleToolBarNextToolTip"));
    jbNext.setVerticalTextPosition(JButton.BOTTOM);
    jbNext.setHorizontalTextPosition(JButton.CENTER);
    jbNext.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            nextThrottleFrame();
        }
    });
    throttleToolBar.add(jbNext);
    jbNextRunning = new JButton();
    jbNextRunning.setIcon(new NamedIcon("resources/icons/throttles/next-jump.png", "resources/icons/throttles/next-jump.png"));
    jbNextRunning.setToolTipText(Bundle.getMessage("ThrottleToolBarNextRunToolTip"));
    jbNextRunning.setVerticalTextPosition(JButton.BOTTOM);
    jbNextRunning.setHorizontalTextPosition(JButton.CENTER);
    jbNextRunning.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            nextRunningThrottleFrame();
        }
    });
    throttleToolBar.add(jbNextRunning);
    throttleToolBar.addSeparator();
    throttleToolBar.add(new StopAllButton());
    if (powerMgr != null) {
        throttleToolBar.add(new LargePowerManagerButton());
    }
    throttleToolBar.addSeparator();
    jbMode = new JButton();
    jbMode.setIcon(new NamedIcon("resources/icons/throttles/edit-view.png", "resources/icons/throttles/edit-view.png"));
    jbMode.setToolTipText(Bundle.getMessage("ThrottleToolBarEditToolTip"));
    jbMode.setVerticalTextPosition(JButton.BOTTOM);
    jbMode.setHorizontalTextPosition(JButton.CENTER);
    jbMode.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            switchMode();
        }
    });
    throttleToolBar.add(jbMode);
    throttleToolBar.addSeparator();
    jbThrottleList = new JButton();
    jbThrottleList.setIcon(new NamedIcon("resources/icons/throttles/list.png", "resources/icons/throttles/list.png"));
    jbThrottleList.setToolTipText(Bundle.getMessage("ThrottleToolBarOpenThrottleListToolTip"));
    jbThrottleList.setVerticalTextPosition(JButton.BOTTOM);
    jbThrottleList.setHorizontalTextPosition(JButton.CENTER);
    jbThrottleList.addActionListener(new ThrottlesListAction());
    throttleToolBar.add(jbThrottleList);
    // Receptacle for Jynstruments
    new FileDrop(throttleToolBar, new Listener() {

        @Override
        public void filesDropped(File[] files) {
            for (int i = 0; i < files.length; i++) {
                ynstrument(files[i].getPath());
            }
        }
    });
    add(throttleToolBar, BorderLayout.PAGE_START);
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) ActionListener(java.awt.event.ActionListener) ItemListener(java.awt.event.ItemListener) Listener(jmri.util.iharder.dnd.FileDrop.Listener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JToolBar(javax.swing.JToolBar) FileDrop(jmri.util.iharder.dnd.FileDrop) ActionListener(java.awt.event.ActionListener) File(java.io.File)

Example 63 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class TurnoutIconWindowTest method testLayoutEditor.

@SuppressWarnings("unchecked")
public void testLayoutEditor() throws Exception {
    if (GraphicsEnvironment.isHeadless()) {
        // can't Assume in TestCase
        return;
    }
    jmri.jmrit.display.layoutEditor.LayoutEditor panel = new jmri.jmrit.display.layoutEditor.LayoutEditor("TurnoutIconWindowTest.testLayoutEditor");
    JComponent jf = panel.getTargetPanel();
    TurnoutIcon icon = new TurnoutIcon(panel);
    icon.setDisplayLevel(Editor.TURNOUTS);
    Turnout sn = jmri.InstanceManager.turnoutManagerInstance().provideTurnout("IT1");
    icon.setTurnout("IT1");
    icon.setIcon("TurnoutStateClosed", new NamedIcon("resources/icons/smallschematics/tracksegments/os-lefthand-east-closed.gif", "resources/icons/smallschematics/tracksegments/os-lefthand-east-closed.gif"));
    icon.setIcon("TurnoutStateThrown", new NamedIcon("resources/icons/smallschematics/tracksegments/os-lefthand-east-thrown.gif", "resources/icons/smallschematics/tracksegments/os-lefthand-east-thrown.gif"));
    icon.setIcon("BeanStateInconsistent", new NamedIcon("resources/icons/smallschematics/tracksegments/os-lefthand-east-error.gif", "resources/icons/smallschematics/tracksegments/os-lefthand-east-error.gif"));
    icon.setIcon("BeanStateUnknown", new NamedIcon("resources/icons/smallschematics/tracksegments/os-lefthand-east-unknown.gif", "resources/icons/smallschematics/tracksegments/os-lefthand-east-unknown.gif"));
    panel.putItem(icon);
    panel.setVisible(true);
    Assert.assertEquals("initial state", Turnout.UNKNOWN, sn.getState());
    // Click icon change state to Active
    java.awt.Point location = new java.awt.Point(icon.getLocation().x + icon.getSize().width / 2, icon.getLocation().y + icon.getSize().height / 2);
    getHelper().enterClickAndLeave(new MouseEventData(this, // component
    jf, // number clicks
    1, // modifiers
    EventDataConstants.DEFAULT_MOUSE_MODIFIERS, // isPopUpTrigger
    false, // sleeptime
    10, // position
    EventDataConstants.CUSTOM, location));
    Assert.assertEquals("state after one click", Turnout.CLOSED, sn.getState());
    // Click icon change state to inactive
    getHelper().enterClickAndLeave(new MouseEventData(this, icon));
    Assert.assertEquals("state after two clicks", Turnout.THROWN, sn.getState());
    // if OK to here, close window
    TestHelper.disposeWindow(panel.getTargetFrame(), this);
    // that pops dialog, find and press Delete
    List<JDialog> dialogList = new DialogFinder(null).findAll(panel.getTargetFrame());
    JDialog d = dialogList.get(0);
    // Find the button that deletes the panel
    AbstractButtonFinder bf = new AbstractButtonFinder("Delete Panel");
    JButton button = (JButton) bf.find(d, 0);
    Assert.assertNotNull(button);
    // Click button to delete panel and close window
    getHelper().enterClickAndLeave(new MouseEventData(this, button));
    // that pops dialog, find and press Yes - Delete
    dialogList = new DialogFinder(null).findAll(panel.getTargetFrame());
    d = dialogList.get(0);
    // Find the button that deletes the panel
    bf = new AbstractButtonFinder("Yes - Dele");
    button = (JButton) bf.find(d, 0);
    Assert.assertNotNull(button);
    // Click button to delete panel and close window
    getHelper().enterClickAndLeave(new MouseEventData(this, button));
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) MouseEventData(junit.extensions.jfcunit.eventdata.MouseEventData) DialogFinder(junit.extensions.jfcunit.finder.DialogFinder) AbstractButtonFinder(junit.extensions.jfcunit.finder.AbstractButtonFinder) Turnout(jmri.Turnout) JDialog(javax.swing.JDialog)

Example 64 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class SensorIconWindowTest method testPanelEditor.

// DialogFinder not parameterized
@SuppressWarnings("unchecked")
public void testPanelEditor() throws Exception {
    if (GraphicsEnvironment.isHeadless()) {
        // can't Assume in TestCase
        return;
    }
    jmri.jmrit.display.panelEditor.PanelEditor panel = new jmri.jmrit.display.panelEditor.PanelEditor("SensorIconWindowTest.testPanelEditor");
    JComponent jf = panel.getTargetPanel();
    SensorIcon icon = new SensorIcon(panel);
    panel.putItem(icon);
    Sensor sn = jmri.InstanceManager.sensorManagerInstance().provideSensor("IS1");
    icon.setSensor("IS1");
    icon.setIcon("BeanStateUnknown", new NamedIcon("resources/icons/smallschematics/tracksegments/circuit-error.gif", "resources/icons/smallschematics/tracksegments/circuit-error.gif"));
    //daboudreau added this for Win7
    icon.setDisplayLevel(Editor.SENSORS);
    panel.setVisible(true);
    //jf.setVisible(true);
    Assert.assertEquals("initial state", Sensor.UNKNOWN, sn.getState());
    // Click icon change state to Active
    java.awt.Point location = new java.awt.Point(icon.getLocation().x + icon.getSize().width / 2, icon.getLocation().y + icon.getSize().height / 2);
    getHelper().enterClickAndLeave(new MouseEventData(this, // component
    jf, // number clicks
    1, // modifiers
    EventDataConstants.DEFAULT_MOUSE_MODIFIERS, // isPopUpTrigger
    false, // sleeptime
    10, // position
    EventDataConstants.CUSTOM, location));
    Assert.assertEquals("state after one click", Sensor.INACTIVE, sn.getState());
    // Click icon change state to inactive
    getHelper().enterClickAndLeave(new MouseEventData(this, icon));
    Assert.assertEquals("state after two clicks", Sensor.ACTIVE, sn.getState());
    // if OK to here, close window
    TestHelper.disposeWindow(panel.getTargetFrame(), this);
    // that pops dialog, find and press Delete
    List<JDialog> dialogList = new DialogFinder(null).findAll(panel.getTargetFrame());
    JDialog d = dialogList.get(0);
    // Find the button that deletes the panel
    AbstractButtonFinder bf = new AbstractButtonFinder("Delete Panel");
    JButton button = (JButton) bf.find(d, 0);
    Assert.assertNotNull(button);
    // Click button to delete panel and close window
    getHelper().enterClickAndLeave(new MouseEventData(this, button));
    // that pops dialog, find and press Yes - Delete
    dialogList = new DialogFinder(null).findAll(panel.getTargetFrame());
    d = dialogList.get(0);
    // Find the button that deletes the panel
    bf = new AbstractButtonFinder("Yes - Dele");
    button = (JButton) bf.find(d, 0);
    Assert.assertNotNull(button);
    // Click button to delete panel and close window
    getHelper().enterClickAndLeave(new MouseEventData(this, button));
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) MouseEventData(junit.extensions.jfcunit.eventdata.MouseEventData) DialogFinder(junit.extensions.jfcunit.finder.DialogFinder) AbstractButtonFinder(junit.extensions.jfcunit.finder.AbstractButtonFinder) JDialog(javax.swing.JDialog) Sensor(jmri.Sensor)

Example 65 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class SensorIconWindowTest method testLayoutEditor.

// DialogFinder not parameterized
@SuppressWarnings("unchecked")
public void testLayoutEditor() throws Exception {
    if (GraphicsEnvironment.isHeadless()) {
        // can't Assume in TestCase
        return;
    }
    jmri.jmrit.display.layoutEditor.LayoutEditor panel = new jmri.jmrit.display.layoutEditor.LayoutEditor("SensorIconWindowTest.testLayoutEditor");
    JComponent jf = panel.getTargetPanel();
    SensorIcon icon = new SensorIcon(panel);
    panel.putItem(icon);
    Sensor sn = jmri.InstanceManager.sensorManagerInstance().provideSensor("IS1");
    icon.setSensor("IS1");
    icon.setIcon("BeanStateUnknown", new NamedIcon("resources/icons/smallschematics/tracksegments/circuit-error.gif", "resources/icons/smallschematics/tracksegments/circuit-error.gif"));
    //daboudreau added this for Win7
    icon.setDisplayLevel(Editor.SENSORS);
    panel.setVisible(true);
    //jf.setVisible(true);
    Assert.assertEquals("initial state", Sensor.UNKNOWN, sn.getState());
    // Click icon change state to Active
    java.awt.Point location = new java.awt.Point(icon.getLocation().x + icon.getSize().width / 2, icon.getLocation().y + icon.getSize().height / 2);
    getHelper().enterClickAndLeave(new MouseEventData(this, // component
    jf, // number clicks
    1, // modifiers
    EventDataConstants.DEFAULT_MOUSE_MODIFIERS, // isPopUpTrigger
    false, // sleeptime
    10, // position
    EventDataConstants.CUSTOM, location));
    Assert.assertEquals("state after one click", Sensor.INACTIVE, sn.getState());
    // Click icon change state to inactive
    getHelper().enterClickAndLeave(new MouseEventData(this, icon));
    Assert.assertEquals("state after two clicks", Sensor.ACTIVE, sn.getState());
    // if OK to here, close window
    TestHelper.disposeWindow(panel.getTargetFrame(), this);
    // that pops dialog, find and press Delete
    List<JDialog> dialogList = new DialogFinder(null).findAll(panel.getTargetFrame());
    JDialog d = dialogList.get(0);
    // Find the button that deletes the panel
    AbstractButtonFinder bf = new AbstractButtonFinder("Delete Panel");
    JButton button = (JButton) bf.find(d, 0);
    Assert.assertNotNull(button);
    // Click button to delete panel and close window
    getHelper().enterClickAndLeave(new MouseEventData(this, button));
    // that pops dialog, find and press Yes - Delete
    dialogList = new DialogFinder(null).findAll(panel.getTargetFrame());
    d = dialogList.get(0);
    // Find the button that deletes the panel
    bf = new AbstractButtonFinder("Yes - Dele");
    button = (JButton) bf.find(d, 0);
    Assert.assertNotNull(button);
    // Click button to delete panel and close window
    getHelper().enterClickAndLeave(new MouseEventData(this, button));
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) MouseEventData(junit.extensions.jfcunit.eventdata.MouseEventData) DialogFinder(junit.extensions.jfcunit.finder.DialogFinder) AbstractButtonFinder(junit.extensions.jfcunit.finder.AbstractButtonFinder) JDialog(javax.swing.JDialog) Sensor(jmri.Sensor)

Aggregations

NamedIcon (jmri.jmrit.catalog.NamedIcon)128 Entry (java.util.Map.Entry)28 Element (org.jdom2.Element)27 HashMap (java.util.HashMap)23 JPanel (javax.swing.JPanel)13 Editor (jmri.jmrit.display.Editor)13 Attribute (org.jdom2.Attribute)13 ActionEvent (java.awt.event.ActionEvent)12 ActionListener (java.awt.event.ActionListener)12 JLabel (javax.swing.JLabel)11 JButton (javax.swing.JButton)10 DataFlavor (java.awt.datatransfer.DataFlavor)6 CatalogTreeNode (jmri.jmrit.catalog.CatalogTreeNode)6 DragJLabel (jmri.jmrit.catalog.DragJLabel)6 Sensor (jmri.Sensor)5 CatalogTreeLeaf (jmri.jmrit.catalog.CatalogTreeLeaf)5 RosterEntry (jmri.jmrit.roster.RosterEntry)5 Point (java.awt.Point)4 JComponent (javax.swing.JComponent)4 JDialog (javax.swing.JDialog)4