All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jdplus.toolkit.desktop.plugin.ui.properties.l2fprod.StringCollectionEditor Maven / Gradle / Ivy

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jdplus.toolkit.desktop.plugin.ui.properties.l2fprod;

import com.l2fprod.common.beans.editor.AbstractPropertyEditor;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.SwingUtilities;

/**
 *
 * @author Kristof Bayens
 */
public class StringCollectionEditor extends AbstractPropertyEditor {
    private String[] strings_;

    public StringCollectionEditor() {
        editor = new JButton(new AbstractAction("...") {

            @Override
            public void actionPerformed(ActionEvent e) {
                ArrayEditorDialog dialog = new ArrayEditorDialog<>(SwingUtilities.getWindowAncestor(editor),
                    null != strings_ ? strings_ : new String[]{}, 
                        ()->"", s->s);
                dialog.setVisible(true);
                setValue(dialog.getElements().toArray(String[]::new));
            }
        });
    }

    @Override
    public Object getValue() {
        return strings_;
    }

    @Override
    public void setValue(Object value) {
        if (null != value && value instanceof String[]) {
            String[] old = strings_;
            strings_ = (String[]) value;
            firePropertyChange(old, strings_);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy