Example usage for javax.swing SpinnerListModel getList

List of usage examples for javax.swing SpinnerListModel getList

Introduction

In this page you can find the example usage for javax.swing SpinnerListModel getList.

Prototype

public List<?> getList() 

Source Link

Document

Returns the List that defines the sequence for this model.

Usage

From source file:org.eclipse.wb.internal.swing.model.property.editor.models.spinner.ListSpinnerComposite.java

@Override
public boolean setModel(SpinnerModel model) {
    if (model instanceof SpinnerListModel) {
        SpinnerListModel listModel = (SpinnerListModel) model;
        String text = StringUtils.join(listModel.getList().iterator(), "\n");
        m_textWidget.setText(text);/*from  ww w. ja v  a 2s  .co m*/
        // OK, this is our model
        return true;
    }
    return false;
}

From source file:org.eclipse.wb.internal.swing.model.property.editor.models.spinner.SpinnerModelPropertyEditor.java

/**
 * @return the text to display for given {@link Property}.
 *//*from ww w.  ja v a  2 s  .c o m*/
private String getText(Property property, boolean forTooltip) throws Exception {
    Object value = property.getValue();
    if (value instanceof SpinnerModel) {
        SpinnerModel model = (SpinnerModel) value;
        // analyze known models
        if (model instanceof SpinnerNumberModel) {
            SpinnerNumberModel numberModel = (SpinnerNumberModel) model;
            // prepare labels
            String typeLabel = forTooltip ? "type=" : "";
            String valueLabel = forTooltip ? " value=" : ", ";
            String startLabel = forTooltip ? " start=" : ", ";
            String endLabel = forTooltip ? " end=" : ", ";
            String stepLabel = forTooltip ? " step=" : ", ";
            // text
            String typeText = typeLabel + CodeUtils.getShortClass(numberModel.getValue().getClass().getName());
            String valueText = valueLabel + numberModel.getValue();
            String startText = startLabel + numberModel.getMinimum();
            String endText = endLabel + numberModel.getMaximum();
            String stepText = stepLabel + numberModel.getStepSize();
            return typeText + valueText + startText + endText + stepText;
        } else if (model instanceof SpinnerListModel) {
            SpinnerListModel listModel = (SpinnerListModel) model;
            String separator = forTooltip ? "\n" : ", ";
            return StringUtils.join(listModel.getList().iterator(), separator);
        } else if (model instanceof SpinnerDateModel) {
            SpinnerDateModel dateModel = (SpinnerDateModel) model;
            // prepare labels
            String valueLabel = forTooltip ? "value=" : "";
            String startLabel = forTooltip ? "\nstart=" : ", ";
            String endLabel = forTooltip ? "\nend=" : ", ";
            String stepLabel = forTooltip ? "\nstep=" : ", ";
            // text
            String valueText = valueLabel + getDateText(dateModel.getValue());
            String startText = startLabel + getDateText(dateModel.getStart());
            String endText = endLabel + getDateText(dateModel.getEnd());
            String stepText = stepLabel + getDateStep(dateModel.getCalendarField());
            return valueText + startText + endText + stepText;
        } else {
            return model.toString();
        }
    }
    // unknown value
    return null;
}