/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 2011 Neil C Smith. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 3 for more details. * * You should have received a copy of the GNU General Public License version 3 * along with this work; if not, see http://www.gnu.org/licenses/ * * * Please visit http://neilcsmith.net if you need additional information or * have any questions. */ /* * StringCustomEditor.java * * Created on 10-Jun-2011, 10:57:46 */ package net.neilcsmith.praxis.live.pxr.editors; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyEditor; import org.openide.explorer.propertysheet.PropertyEnv; /** * * @author Neil C Smith (http://neilcsmith.net) */ class StringCustomEditor extends javax.swing.JPanel implements PropertyChangeListener { private final PropertyEditor editor; private final PropertyEnv env; /** Creates new form StringCustomEditor */ StringCustomEditor(PropertyEditor editor, PropertyEnv env) { this.editor = editor; this.env = env; initComponents(); env.setState(PropertyEnv.STATE_NEEDS_VALIDATION); env.addPropertyChangeListener(this); textArea.setText(editor.getAsText()); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { scrollPane = new javax.swing.JScrollPane(); textArea = new javax.swing.JTextArea(); textArea.setColumns(20); textArea.setRows(5); scrollPane.setViewportView(textArea); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE) ); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane scrollPane; private javax.swing.JTextArea textArea; // End of variables declaration//GEN-END:variables @Override public void propertyChange(PropertyChangeEvent evt) { if (PropertyEnv.PROP_STATE.equals(evt.getPropertyName()) && evt.getNewValue() == PropertyEnv.STATE_VALID) { editor.setAsText(textArea.getText()); } } }