alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.modules.javacvs.editors;

import java.beans.*;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.netbeans.lib.cvsclient.command.KeywordSubstitutionOptions;


import org.openide.util.NbBundle;

/** Property editor for keyword substitution property of some commands
*
* @author Milos Kleint

*/
public class KeywordSubstitutionPropertyEditor extends PropertyEditorSupport {

    private static final java.util.ResourceBundle bundle = NbBundle.getBundle(KeywordSubstitutionPropertyEditor.class);

    private static final String K_NONE = bundle.getString("KeywordSubstitutionPE.NoSubstitution"); //NOI18N
    private static final String K_BINARY = bundle.getString("KeywordSubstitutionPE.BinarySubst"); //NOI18N
    private static final String K_KEYWORD_VALUE = bundle.getString("KeywordSubstitutionPE.KeywordValueSubst"); //NOI18N
    private static final String K_KEYWORD_VALUE_LOCKER = bundle.getString("KeywordSubstitutionPE.KeywordValueLockerSubst"); //NOI18N
    private static final String K_KEYWORD = bundle.getString("KeywordSubstitutionPE.Keyword"); //NOI18N
    private static final String K_VALUE = bundle.getString("KeywordSubstitutionPE.Value"); //NOI18N
    private static final String K_OLD = bundle.getString("KeywordSubstitutionPE.Old"); //NOI18N
    
    private String[] values = new String[] { K_NONE, K_BINARY, K_KEYWORD_VALUE, 
                K_KEYWORD_VALUE_LOCKER, K_KEYWORD, K_VALUE, K_OLD} ;
                
    private KeywordSubstitutionOptions[] cvsValues = new KeywordSubstitutionOptions[] { null, KeywordSubstitutionOptions.BINARY, KeywordSubstitutionOptions.DEFAULT, 
                            KeywordSubstitutionOptions.DEFAULT_LOCKER, KeywordSubstitutionOptions.ONLY_KEYWORDS, 
                            KeywordSubstitutionOptions.ONLY_VALUES, KeywordSubstitutionOptions.OLD_VALUES };

    /** @return names of the supported LookAndFeels */
    public String[] getTags() {
        return values;
    }

    /** @return text for the current value */
    public String getAsText () {
        if (getValue() == null) return K_NONE;
        KeywordSubstitutionOptions mode = (KeywordSubstitutionOptions) getValue();
        for (int i = 0; i < cvsValues.length; i++) {
            if (mode.equals(cvsValues[i])) {
                return values[i];
            }
        }
        return K_NONE;
    }

    /** @param text A text for the current value. */
    public void setAsText (String text) {
        for (int i = 0; i < cvsValues.length; i++) {
            if (text.equals(values[i])) {
                setValue(cvsValues[i]);
                return;
            }
        }
        throw new IllegalArgumentException ();
    }

    public Object getValue() {
        return super.getValue();
    }
    public void setValue(Object value) {
        super.setValue(value);
    }
}

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.