Search in sources :

Example 46 with JSeparator

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

the class LayoutTurntable method showPopUp.

/**
     * Display popup menu for information and editing
     */
protected void showPopUp(MouseEvent e) {
    if (popup != null) {
        popup.removeAll();
    } else {
        popup = new JPopupMenu();
    }
    JMenuItem jmi = popup.add(rb.getString("Turntable"));
    jmi.setEnabled(false);
    popup.add(new JSeparator(JSeparator.HORIZONTAL));
    popup.add(new AbstractAction(Bundle.getMessage("ButtonEdit")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            editTurntable(instance);
        }
    });
    popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (layoutEditor.removeTurntable(instance)) {
                // Returned true if user did not cancel
                remove();
                dispose();
            }
        }
    });
    layoutEditor.setShowAlignmentMenu(popup);
    popup.show(e.getComponent(), e.getX(), e.getY());
}
Also used : ActionEvent(java.awt.event.ActionEvent) JMenuItem(javax.swing.JMenuItem) AbstractAction(javax.swing.AbstractAction) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator)

Example 47 with JSeparator

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

the class TrackSegment method showPopUp.

/**
     * Display popup menu for information and editing.
     */
protected void showPopUp(MouseEvent e) {
    if (popup != null) {
        popup.removeAll();
    } else {
        popup = new JPopupMenu();
    }
    String info = rb.getString("TrackSegment");
    if (getArc()) {
        if (getCircle()) {
            info = info + " (" + Bundle.getMessage("Circle") + ")";
        } else {
            info = info + " (" + Bundle.getMessage("Ellipse") + ")";
        }
    } else if (getBezier()) {
        info = info + " (" + Bundle.getMessage("Bezier") + ")";
    } else {
        info = info + " (" + Bundle.getMessage("Line") + ")";
    }
    JMenuItem jmi = popup.add(info);
    jmi.setEnabled(false);
    jmi = popup.add(ident);
    jmi.setEnabled(false);
    if (!dashed) {
        jmi = popup.add(rb.getString("Style") + " - " + rb.getString("Solid"));
    } else {
        jmi = popup.add(rb.getString("Style") + " - " + rb.getString("Dashed"));
    }
    jmi.setEnabled(false);
    if (!mainline) {
        jmi = popup.add(rb.getString("NotMainline"));
    } else {
        jmi = popup.add(rb.getString("Mainline"));
    }
    jmi.setEnabled(false);
    if (blockName.equals("")) {
        jmi = popup.add(rb.getString("NoBlock"));
    } else {
        jmi = popup.add(Bundle.getMessage("BeanNameBlock") + ": " + getLayoutBlock().getID());
    }
    jmi.setEnabled(false);
    if (hidden) {
        jmi = popup.add(rb.getString("Hidden"));
    } else {
        jmi = popup.add(rb.getString("NotHidden"));
    }
    jmi.setEnabled(false);
    popup.add(new JSeparator(JSeparator.HORIZONTAL));
    popup.add(new AbstractAction(Bundle.getMessage("ButtonEdit")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            editTrackSegment();
        }
    });
    popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            layoutEditor.removeTrackSegment(instance);
            remove();
            dispose();
        }
    });
    JMenu lineType = new JMenu(rb.getString("ChangeTo"));
    lineType.add(new AbstractAction(Bundle.getMessage("Line")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeType(0);
        }
    });
    lineType.add(new AbstractAction(Bundle.getMessage("Circle")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeType(1);
        }
    });
    lineType.add(new AbstractAction(Bundle.getMessage("Ellipse")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeType(2);
        }
    });
    lineType.add(new AbstractAction(Bundle.getMessage("Bezier")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeType(3);
        }
    });
    popup.add(lineType);
    if (getArc()) {
        popup.add(new AbstractAction(rb.getString("FlipAngle")) {

            @Override
            public void actionPerformed(ActionEvent e) {
                flipAngle();
            }
        });
    }
    if (getArc() || getBezier()) {
        if (hideConstructionLines()) {
            popup.add(new AbstractAction(rb.getString("ShowConstruct")) {

                @Override
                public void actionPerformed(ActionEvent e) {
                    hideConstructionLines(SHOWCON);
                }
            });
        } else {
            popup.add(new AbstractAction(rb.getString("HideConstruct")) {

                @Override
                public void actionPerformed(ActionEvent e) {
                    hideConstructionLines(HIDECON);
                }
            });
        }
    }
    if ((!blockName.equals("")) && (jmri.InstanceManager.getDefault(LayoutBlockManager.class).isAdvancedRoutingEnabled())) {
        popup.add(new AbstractAction(rb.getString("ViewBlockRouting")) {

            @Override
            public void actionPerformed(ActionEvent e) {
                AbstractAction routeTableAction = new LayoutBlockRouteTableAction("ViewRouting", getLayoutBlock());
                routeTableAction.actionPerformed(e);
            }
        });
    }
    popup.show(e.getComponent(), e.getX(), e.getY());
}
Also used : ActionEvent(java.awt.event.ActionEvent) LayoutBlockRouteTableAction(jmri.jmrit.display.layoutEditor.blockRoutingTable.LayoutBlockRouteTableAction) JMenuItem(javax.swing.JMenuItem) AbstractAction(javax.swing.AbstractAction) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator) JMenu(javax.swing.JMenu)

Example 48 with JSeparator

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

the class PaneProgPane method newGridItem.

/**
     * Create a grid item from the JDOM Element
     *
     * @param element     element containing grid item contents
     * @param showStdName show the name following the rules for the
     * <em>nameFmt</em> element
     * @param modelElem   element containing the decoder model
     * @param globs       properties to configure the layout
     * @return a panel containing the group
     */
public JPanel newGridItem(Element element, boolean showStdName, Element modelElem, GridGlobals globs) {
    // get item-level attributes
    List<Attribute> itemAttList = element.getAttributes();
    List<Attribute> attList = new ArrayList<>(globs.gridAttList);
    // merge grid and item-level attributes
    attList.addAll(itemAttList);
    //                log.info("New gridtiem -----------------------------------------------");
    //                log.info("Attribute list:"+attList);
    attList.add(new Attribute(LAST_GRIDX, ""));
    attList.add(new Attribute(LAST_GRIDY, ""));
    //                log.info("Previous gridxCurrent="+globs.gridxCurrent+";gridyCurrent="+globs.gridyCurrent);
    for (int j = 0; j < attList.size(); j++) {
        Attribute attrib = attList.get(j);
        String attribName = attrib.getName();
        String attribRawValue = attrib.getValue();
        Field constraint = null;
        String constraintType = null;
        // make sure we only process the last gridx or gridy attribute in the list
        if (attribName.equals("gridx")) {
            Attribute a = new Attribute(LAST_GRIDX, attribRawValue);
            attList.set(attList.size() - 2, a);
            //. don't process now
            continue;
        }
        if (attribName.equals("gridy")) {
            Attribute a = new Attribute(LAST_GRIDY, attribRawValue);
            attList.set(attList.size() - 1, a);
            //. don't process now
            continue;
        }
        if (attribName.equals(LAST_GRIDX)) {
            // we must be at end of original list, restore last gridx
            attribName = "gridx";
            if (attribRawValue.equals("")) {
                // don't process blank (unused)
                continue;
            }
        }
        if (attribName.equals(LAST_GRIDY)) {
            // we must be at end of original list, restore last gridy
            attribName = "gridy";
            if (attribRawValue.equals("")) {
                // don't process blank (unused)
                continue;
            }
        }
        if ((attribName.equals("gridx") || attribName.equals("gridy")) && attribRawValue.equals("RELATIVE")) {
            // NEXT is a synonym for RELATIVE
            attribRawValue = "NEXT";
        }
        if (attribName.equals("gridx") && attribRawValue.equals("CURRENT")) {
            attribRawValue = String.valueOf(Math.max(0, globs.gridxCurrent));
        }
        if (attribName.equals("gridy") && attribRawValue.equals("CURRENT")) {
            attribRawValue = String.valueOf(Math.max(0, globs.gridyCurrent));
        }
        if (attribName.equals("gridx") && attribRawValue.equals("NEXT")) {
            attribRawValue = String.valueOf(++globs.gridxCurrent);
        }
        if (attribName.equals("gridy") && attribRawValue.equals("NEXT")) {
            attribRawValue = String.valueOf(++globs.gridyCurrent);
        }
        //                    log.info("attribName="+attribName+";attribRawValue="+attribRawValue);
        try {
            constraint = globs.gridConstraints.getClass().getDeclaredField(attribName);
            constraintType = constraint.getType().toString();
            constraint.setAccessible(true);
        } catch (NoSuchFieldException ex) {
            log.error("Unrecognised attribute \"" + attribName + "\", skipping");
            continue;
        }
        switch(constraintType) {
            case "int":
                {
                    int attribValue;
                    try {
                        attribValue = Integer.valueOf(attribRawValue);
                        constraint.set(globs.gridConstraints, attribValue);
                    } catch (IllegalAccessException ey) {
                        log.error("Unable to set constraint \"" + attribName + ". IllegalAccessException error thrown.");
                    } catch (NumberFormatException ex) {
                        try {
                            Field constant = globs.gridConstraints.getClass().getDeclaredField(attribRawValue);
                            constant.setAccessible(true);
                            attribValue = (Integer) GridBagConstraints.class.getField(attribRawValue).get(constant);
                            constraint.set(globs.gridConstraints, attribValue);
                        } catch (NoSuchFieldException ey) {
                            log.error("Invalid value \"" + attribRawValue + "\" for attribute \"" + attribName + "\"");
                        } catch (IllegalAccessException ey) {
                            log.error("Unable to set constraint \"" + attribName + ". IllegalAccessException error thrown.");
                        }
                    }
                    break;
                }
            case "double":
                {
                    double attribValue;
                    try {
                        attribValue = Double.valueOf(attribRawValue);
                        constraint.set(globs.gridConstraints, attribValue);
                    } catch (IllegalAccessException ey) {
                        log.error("Unable to set constraint \"" + attribName + ". IllegalAccessException error thrown.");
                    } catch (NumberFormatException ex) {
                        log.error("Invalid value \"" + attribRawValue + "\" for attribute \"" + attribName + "\"");
                    }
                    break;
                }
            case "class java.awt.Insets":
                try {
                    String[] insetStrings = attribRawValue.split(",");
                    if (insetStrings.length == 4) {
                        Insets attribValue = new Insets(Integer.valueOf(insetStrings[0]), Integer.valueOf(insetStrings[1]), Integer.valueOf(insetStrings[2]), Integer.valueOf(insetStrings[3]));
                        constraint.set(globs.gridConstraints, attribValue);
                    } else {
                        log.error("Invalid value \"" + attribRawValue + "\" for attribute \"" + attribName + "\"");
                        log.error("Value should be four integers of the form \"top,left,bottom,right\"");
                    }
                } catch (IllegalAccessException ey) {
                    log.error("Unable to set constraint \"" + attribName + ". IllegalAccessException error thrown.");
                } catch (NumberFormatException ex) {
                    log.error("Invalid value \"" + attribRawValue + "\" for attribute \"" + attribName + "\"");
                    log.error("Value should be four integers of the form \"top,left,bottom,right\"");
                }
                break;
            default:
                log.error("Required \"" + constraintType + "\" handler for attribute \"" + attribName + "\" not defined in JMRI code");
                log.error("Please file a JMRI bug report at https://sourceforge.net/p/jmri/bugs/new/");
                break;
        }
    }
    //                log.info("Updated globs.GridBagConstraints.gridx="+globs.gridConstraints.gridx+";globs.GridBagConstraints.gridy="+globs.gridConstraints.gridy);
    // create a panel to add as a new grid item
    final JPanel c = new JPanel();
    panelList.add(c);
    GridBagLayout g = new GridBagLayout();
    GridBagConstraints cs = new GridBagConstraints();
    c.setLayout(g);
    // handle the xml definition
    // for all elements in the grid item
    List<Element> elemList = element.getChildren();
    log.trace("newGridItem starting with {} elements", elemList.size());
    for (int i = 0; i < elemList.size(); i++) {
        // update the grid position
        cs.gridy = 0;
        cs.gridx++;
        Element e = elemList.get(i);
        String name = e.getName();
        log.trace("newGridItem processing {} element", name);
        // decode the type
        if (name.equals("display")) {
            // its a variable
            // load the variable
            newVariable(e, c, g, cs, showStdName);
        } else if (name.equals("separator")) {
            // its a separator
            JSeparator j = new JSeparator(javax.swing.SwingConstants.VERTICAL);
            cs.fill = GridBagConstraints.BOTH;
            cs.gridheight = GridBagConstraints.REMAINDER;
            g.setConstraints(j, cs);
            c.add(j);
            cs.fill = GridBagConstraints.NONE;
            cs.gridheight = 1;
        } else if (name.equals("label")) {
            cs.gridheight = GridBagConstraints.REMAINDER;
            makeLabel(e, c, g, cs);
        } else if (name.equals("soundlabel")) {
            cs.gridheight = GridBagConstraints.REMAINDER;
            makeSoundLabel(e, c, g, cs);
        } else if (name.equals("cvtable")) {
            makeCvTable(cs, g, c);
        } else if (name.equals("indxcvtable")) {
            log.debug("starting to build IndexedCvTable pane");
            JTable indxcvTable = new JTable(_indexedCvModel);
            JScrollPane cvScroll = new JScrollPane(indxcvTable);
            indxcvTable.setDefaultRenderer(JTextField.class, new ValueRenderer());
            indxcvTable.setDefaultRenderer(JButton.class, new ValueRenderer());
            indxcvTable.setDefaultEditor(JTextField.class, new ValueEditor());
            indxcvTable.setDefaultEditor(JButton.class, new ValueEditor());
            indxcvTable.setRowHeight(new JButton("X").getPreferredSize().height);
            indxcvTable.setPreferredScrollableViewportSize(new Dimension(700, indxcvTable.getRowHeight() * 14));
            cvScroll.setColumnHeaderView(indxcvTable.getTableHeader());
            // don't want a horizontal scroll bar
            // Need to see the whole row at one time
            //                indxcvTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            cs.gridwidth = GridBagConstraints.REMAINDER;
            g.setConstraints(cvScroll, cs);
            c.add(cvScroll);
            cs.gridwidth = 1;
            // remember which indexed CVs to read/write
            for (int j = 0; j < _indexedCvModel.getRowCount(); j++) {
                String sz = "CV" + _indexedCvModel.getName(j);
                int in = _varModel.findVarIndex(sz);
                indexedCvList.add(in);
            }
            _cvTable = true;
            log.debug("end of building IndexedCvTable pane");
        } else if (name.equals("fnmapping")) {
            pickFnMapPanel(c, g, cs, modelElem);
        } else if (name.equals("dccaddress")) {
            JPanel l = addDccAddressPanel(e);
            if (l.getComponentCount() > 0) {
                cs.gridheight = GridBagConstraints.REMAINDER;
                g.setConstraints(l, cs);
                c.add(l);
                cs.gridheight = 1;
            }
        } else if (name.equals("column")) {
            // nested "column" elements ...
            cs.gridheight = GridBagConstraints.REMAINDER;
            JPanel l = newColumn(e, showStdName, modelElem);
            if (l.getComponentCount() > 0) {
                panelList.add(l);
                g.setConstraints(l, cs);
                c.add(l);
                cs.gridheight = 1;
            }
        } else if (name.equals("row")) {
            // nested "row" elements ...
            cs.gridwidth = GridBagConstraints.REMAINDER;
            JPanel l = newRow(e, showStdName, modelElem);
            if (l.getComponentCount() > 0) {
                panelList.add(l);
                g.setConstraints(l, cs);
                c.add(l);
                cs.gridwidth = 1;
            }
        } else if (name.equals("grid")) {
            // nested "grid" elements ...
            cs.gridwidth = GridBagConstraints.REMAINDER;
            JPanel l = newGrid(e, showStdName, modelElem);
            if (l.getComponentCount() > 0) {
                panelList.add(l);
                g.setConstraints(l, cs);
                c.add(l);
                cs.gridwidth = 1;
            }
        } else if (name.equals("group")) {
            // nested "group" elements ...
            JPanel l = newGroup(e, showStdName, modelElem);
            if (l.getComponentCount() > 0) {
                panelList.add(l);
                g.setConstraints(l, cs);
                c.add(l);
            }
        } else if (!name.equals("qualifier")) {
            // its a mistake
            log.error("No code to handle element of type " + e.getName() + " in newGridItem");
        }
    }
    globs.gridxCurrent = globs.gridConstraints.gridx;
    globs.gridyCurrent = globs.gridConstraints.gridy;
    // add glue to the bottom to allow resize
    if (c.getComponentCount() > 0) {
        c.add(Box.createVerticalGlue());
    }
    // handle qualification if any
    QualifierAdder qa = new QualifierAdder() {

        @Override
        protected Qualifier createQualifier(VariableValue var, String relation, String value) {
            return new JComponentQualifier(c, var, Integer.parseInt(value), relation);
        }

        @Override
        protected void addListener(java.beans.PropertyChangeListener qc) {
            c.addPropertyChangeListener(qc);
        }
    };
    qa.processModifierElements(element, _varModel);
    return c;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) ValueRenderer(jmri.jmrit.symbolicprog.ValueRenderer) JTextField(javax.swing.JTextField) Field(java.lang.reflect.Field) QualifierAdder(jmri.jmrit.symbolicprog.QualifierAdder) JScrollPane(javax.swing.JScrollPane) VariableValue(jmri.jmrit.symbolicprog.VariableValue) ValueEditor(jmri.jmrit.symbolicprog.ValueEditor) Dimension(java.awt.Dimension) JTable(javax.swing.JTable)

Example 49 with JSeparator

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

the class PaneProgPane method newRow.

/**
     * Create a single row from the JDOM column Element
     *
     * @param element     element containing row contents
     * @param showStdName show the name following the rules for the
     * <em>nameFmt</em> element
     * @param modelElem   element containing the decoder model
     * @return a panel containing the group
     */
public JPanel newRow(Element element, boolean showStdName, Element modelElem) {
    // create a panel to add as a new column or row
    final JPanel c = new JPanel();
    panelList.add(c);
    GridBagLayout g = new GridBagLayout();
    GridBagConstraints cs = new GridBagConstraints();
    c.setLayout(g);
    // handle the xml definition
    // for all elements in the column or row
    List<Element> elemList = element.getChildren();
    log.trace("newRow starting with {} elements", elemList.size());
    for (int i = 0; i < elemList.size(); i++) {
        // update the grid position
        cs.gridy = 0;
        cs.gridx++;
        Element e = elemList.get(i);
        String name = e.getName();
        log.trace("newRow processing {} element", name);
        // decode the type
        if (name.equals("display")) {
            // its a variable
            // load the variable
            newVariable(e, c, g, cs, showStdName);
        } else if (name.equals("separator")) {
            // its a separator
            JSeparator j = new JSeparator(javax.swing.SwingConstants.VERTICAL);
            cs.fill = GridBagConstraints.BOTH;
            cs.gridheight = GridBagConstraints.REMAINDER;
            g.setConstraints(j, cs);
            c.add(j);
            cs.fill = GridBagConstraints.NONE;
            cs.gridheight = 1;
        } else if (name.equals("label")) {
            cs.gridheight = GridBagConstraints.REMAINDER;
            makeLabel(e, c, g, cs);
        } else if (name.equals("soundlabel")) {
            cs.gridheight = GridBagConstraints.REMAINDER;
            makeSoundLabel(e, c, g, cs);
        } else if (name.equals("cvtable")) {
            makeCvTable(cs, g, c);
        } else if (name.equals("indxcvtable")) {
            log.debug("starting to build IndexedCvTable pane");
            JTable indxcvTable = new JTable(_indexedCvModel);
            JScrollPane cvScroll = new JScrollPane(indxcvTable);
            indxcvTable.setDefaultRenderer(JTextField.class, new ValueRenderer());
            indxcvTable.setDefaultRenderer(JButton.class, new ValueRenderer());
            indxcvTable.setDefaultEditor(JTextField.class, new ValueEditor());
            indxcvTable.setDefaultEditor(JButton.class, new ValueEditor());
            indxcvTable.setRowHeight(new JButton("X").getPreferredSize().height);
            indxcvTable.setPreferredScrollableViewportSize(new Dimension(700, indxcvTable.getRowHeight() * 14));
            cvScroll.setColumnHeaderView(indxcvTable.getTableHeader());
            // don't want a horizontal scroll bar
            // Need to see the whole row at one time
            //                indxcvTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            cs.gridwidth = GridBagConstraints.REMAINDER;
            g.setConstraints(cvScroll, cs);
            c.add(cvScroll);
            cs.gridwidth = 1;
            // remember which indexed CVs to read/write
            for (int j = 0; j < _indexedCvModel.getRowCount(); j++) {
                String sz = "CV" + _indexedCvModel.getName(j);
                int in = _varModel.findVarIndex(sz);
                indexedCvList.add(in);
            }
            _cvTable = true;
            log.debug("end of building IndexedCvTable pane");
        } else if (name.equals("fnmapping")) {
            pickFnMapPanel(c, g, cs, modelElem);
        } else if (name.equals("dccaddress")) {
            JPanel l = addDccAddressPanel(e);
            if (l.getComponentCount() > 0) {
                cs.gridheight = GridBagConstraints.REMAINDER;
                g.setConstraints(l, cs);
                c.add(l);
                cs.gridheight = 1;
            }
        } else if (name.equals("column")) {
            // nested "column" elements ...
            cs.gridheight = GridBagConstraints.REMAINDER;
            JPanel l = newColumn(e, showStdName, modelElem);
            if (l.getComponentCount() > 0) {
                panelList.add(l);
                g.setConstraints(l, cs);
                c.add(l);
                cs.gridheight = 1;
            }
        } else if (name.equals("row")) {
            // nested "row" elements ...
            cs.gridwidth = GridBagConstraints.REMAINDER;
            JPanel l = newRow(e, showStdName, modelElem);
            if (l.getComponentCount() > 0) {
                panelList.add(l);
                g.setConstraints(l, cs);
                c.add(l);
                cs.gridwidth = 1;
            }
        } else if (name.equals("grid")) {
            // nested "grid" elements ...
            cs.gridwidth = GridBagConstraints.REMAINDER;
            JPanel l = newGrid(e, showStdName, modelElem);
            if (l.getComponentCount() > 0) {
                panelList.add(l);
                g.setConstraints(l, cs);
                c.add(l);
                cs.gridwidth = 1;
            }
        } else if (name.equals("group")) {
            // nested "group" elements ...
            JPanel l = newGroup(e, showStdName, modelElem);
            if (l.getComponentCount() > 0) {
                panelList.add(l);
                g.setConstraints(l, cs);
                c.add(l);
            }
        } else if (!name.equals("qualifier")) {
            // its a mistake
            log.error("No code to handle element of type " + e.getName() + " in newRow");
        }
    }
    // add glue to the bottom to allow resize
    if (c.getComponentCount() > 0) {
        c.add(Box.createVerticalGlue());
    }
    // handle qualification if any
    QualifierAdder qa = new QualifierAdder() {

        @Override
        protected Qualifier createQualifier(VariableValue var, String relation, String value) {
            return new JComponentQualifier(c, var, Integer.parseInt(value), relation);
        }

        @Override
        protected void addListener(java.beans.PropertyChangeListener qc) {
            c.addPropertyChangeListener(qc);
        }
    };
    qa.processModifierElements(element, _varModel);
    return c;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) VariableValue(jmri.jmrit.symbolicprog.VariableValue) Element(org.jdom2.Element) JButton(javax.swing.JButton) ValueEditor(jmri.jmrit.symbolicprog.ValueEditor) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) ValueRenderer(jmri.jmrit.symbolicprog.ValueRenderer) JTable(javax.swing.JTable) QualifierAdder(jmri.jmrit.symbolicprog.QualifierAdder)

Example 50 with JSeparator

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

the class AbstractLoaderPane method initComponents.

@Override
public void initComponents() throws Exception {
    super.initComponents();
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    {
        /* Create panels for displaying a filename and for providing a file 
             * seleciton pushbutton
             */
        inputFileNamePanel = new JPanel();
        inputFileNamePanel.setLayout(new FlowLayout());
        JLabel l = new JLabel(Bundle.getMessage("LabelInpFile"));
        inputFileLabelWidth = l.getMinimumSize().width;
        l.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
        inputFileNamePanel.add(l);
        inputFileNamePanel.add(new Box.Filler(new java.awt.Dimension(5, 20), new java.awt.Dimension(5, 20), new java.awt.Dimension(5, 20)));
        inputFileNamePanel.add(inputFileName);
        add(inputFileNamePanel);
        JPanel p = new JPanel();
        p.setLayout(new FlowLayout());
        JButton selectButton = new JButton(Bundle.getMessage("ButtonSelect"));
        selectButton.addActionListener((ActionEvent e) -> {
            inputContent = new MemoryContents();
            setDefaultFieldValues();
            updateDownloadVerifyButtons();
            selectInputFile();
            doRead(chooser);
        });
        p.add(selectButton);
        add(p);
    }
    {
        // Create a panel for displaying the addressing type, via radio buttons
        JPanel p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
        JLabel l = new JLabel(Bundle.getMessage("LabelBitMode") + " ");
        l.setEnabled(false);
        p.add(l);
        p.add(address16bit);
        p.add(address24bit);
        addressSizeButtonGroup.add(address16bit);
        addressSizeButtonGroup.add(address24bit);
        addressSizeButtonGroup.clearSelection();
        address16bit.setEnabled(false);
        address24bit.setEnabled(false);
        add(p);
    }
    setDefaultFieldValues();
    add(new JSeparator());
    addOptionsPanel();
    {
        // create a panel for the upload, verify, and abort buttons
        JPanel p = new JPanel();
        p.setLayout(new FlowLayout());
        loadButton = new JButton(Bundle.getMessage("ButtonLoad"));
        loadButton.setEnabled(false);
        loadButton.setToolTipText(Bundle.getMessage("TipLoadDisabled"));
        p.add(loadButton);
        loadButton.addActionListener((java.awt.event.ActionEvent e) -> {
            doLoad();
        });
        verifyButton = new JButton(Bundle.getMessage("ButtonVerify"));
        verifyButton.setEnabled(false);
        verifyButton.setToolTipText(Bundle.getMessage("TipVerifyDisabled"));
        p.add(verifyButton);
        verifyButton.addActionListener((java.awt.event.ActionEvent e) -> {
            doVerify();
        });
        add(p);
        abortButton = new JButton(Bundle.getMessage("ButtonAbort"));
        abortButton.setEnabled(false);
        abortButton.setToolTipText(Bundle.getMessage("TipAbortDisabled"));
        p.add(abortButton);
        abortButton.addActionListener((java.awt.event.ActionEvent e) -> {
            setOperationAborted(true);
        });
        add(p);
        add(new JSeparator());
        // create progress bar
        bar = new JProgressBar(0, 100);
        bar.setStringPainted(true);
        add(bar);
        add(new JSeparator());
        {
            // create a panel for displaying a status message
            p = new JPanel();
            p.setLayout(new FlowLayout());
            status.setText(Bundle.getMessage("StatusSelectFile"));
            status.setAlignmentX(JLabel.LEFT_ALIGNMENT);
            p.add(status);
            add(p);
        }
    }
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JLabel(javax.swing.JLabel) ActionEvent(java.awt.event.ActionEvent) JSeparator(javax.swing.JSeparator) MemoryContents(jmri.jmrit.MemoryContents)

Aggregations

JSeparator (javax.swing.JSeparator)147 JPanel (javax.swing.JPanel)74 JLabel (javax.swing.JLabel)65 ActionEvent (java.awt.event.ActionEvent)44 BoxLayout (javax.swing.BoxLayout)44 JButton (javax.swing.JButton)44 JMenuItem (javax.swing.JMenuItem)38 JMenu (javax.swing.JMenu)32 GridBagConstraints (java.awt.GridBagConstraints)31 Insets (java.awt.Insets)30 ActionListener (java.awt.event.ActionListener)30 Dimension (java.awt.Dimension)24 FlowLayout (java.awt.FlowLayout)24 JScrollPane (javax.swing.JScrollPane)24 GridBagLayout (java.awt.GridBagLayout)22 JPopupMenu (javax.swing.JPopupMenu)19 BorderLayout (java.awt.BorderLayout)16 JTextField (javax.swing.JTextField)16 JCheckBox (javax.swing.JCheckBox)13 AbstractAction (javax.swing.AbstractAction)12