com.clustercontrol.editor.TextAreaPropertyDefine.java Source code

Java tutorial

Introduction

Here is the source code for com.clustercontrol.editor.TextAreaPropertyDefine.java

Source

/*
    
Copyright (C) 2006 NTT DATA Corporation
    
This program is free software; you can redistribute it and/or
Modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, version 2.
    
This program 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 for more details.
    
 */

package com.clustercontrol.editor;

import java.io.Serializable;
import org.eclipse.jface.dialogs.MessageDialog;

import com.clustercontrol.bean.DataRangeConstant;
import com.clustercontrol.bean.Property;
import com.clustercontrol.util.Messages;

/**
 * <BR>
 * 
 * @version 2.0.0
 * @since 2.0.0
 */
public class TextAreaPropertyDefine extends PropertyDefine implements Serializable {

    private static final long serialVersionUID = -5855792499351692500L;

    /**   */
    private String m_title = null;

    /** ??/?? */
    private boolean m_modify = false;

    /**
     * 
     * 
     * @since 2.0.0
     */
    public TextAreaPropertyDefine() {
        m_cellEditor = new TextAreaDialogCellEditor();
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.clustercontrol.bean.PropertyDefine#getColumnText(java.lang.Object)
     */
    @Override
    public String getColumnText(Object value) {
        if (value instanceof String) {
            return (String) value;
        } else {
            return "";
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.clustercontrol.bean.PropertyDefine#getValue(com.clustercontrol.bean.Property)
     */
    @Override
    public Object getValue(Property element) {
        Object value = element.getValue();
        if (value instanceof String) {
            return value;
        } else {
            return "";
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.clustercontrol.bean.PropertyDefine#modify(com.clustercontrol.bean.Property,
     *      java.lang.Object)
     */
    @Override
    public void modify(Property element, Object value) {
        if (value instanceof String) {

            //try {
            if (element.getStringUpperValue() == DataRangeConstant.TEXT) {
                element.setValue(value);
            }
            //else if ( ((String) value).getBytes("UTF-8").length <= element.getStringUpperValue() ) {
            else if (((String) value).length() <= element.getStringUpperValue()) {
                element.setValue(value);
            } else {
                String[] args = { String.valueOf(element.getStringUpperValue()) };

                //
                MessageDialog.openWarning(null, Messages.getString("message.hinemos.1"),
                        Messages.getString("message.hinemos.7", args));
            }
            /*} catch (UnsupportedEncodingException e) {
            }*/
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.clustercontrol.bean.PropertyDefine#initEditer()
     */
    @Override
    public void initEditer() {
        ((TextAreaDialogCellEditor) m_cellEditor).setTitle(m_title);
        ((TextAreaDialogCellEditor) m_cellEditor).setModify(m_modify);
    }

    /**
     * 
     * 
     * @param title ?
     */
    public void setTitle(String title) {
        m_title = title;
    }

    /**
     * ?
     * 
     * @return m_title
     */
    public String getTitle() {
        return m_title;
    }

    /**
     * ??/??
     * 
     * @param title ??/??
     */
    public void setModify(boolean modify) {
        m_modify = modify;
    }

    /**
     * ??/???
     * 
     * @return m_modify
     */
    public boolean getmodify() {
        return m_modify;
    }
}