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-2003 Sun
 * Microsystems, Inc. All Rights Reserved.
 */
package org.netbeans.modules.tasklist.usertasks;

import org.netbeans.modules.tasklist.client.Suggestion;
import org.netbeans.modules.tasklist.client.SuggestionProperty;
import org.netbeans.modules.tasklist.core.TaskProperties;

import java.util.Date;


public class UserTaskProperties extends TaskProperties {
    public static final String PROPID_CATEGORY = "category";
    public static final String PROPID_FILENAME = "filename";
    public static final String PROPID_LINE_NUMBER = "line";
    public static final String PROPID_CREATED_DATE = "created";
    public static final String PROPID_LAST_EDITED_DATE = "edited";
    public static final String PROPID_DUE_DATE = "dueDate";
    public static final String PROPID_DONE = "done";
    public static final String PROPID_PERCENT_COMPLETE = "percentComplete";
    public static final String PROPID_EFFORT = "effort";
    public static final String PROPID_REMAINING_EFFORT = "remainingEffort";
    public static final String PROPID_SPENT_TIME = "spentTime";

    // override to force different strings for the property
    // (it's in fact a different property with the same id)
    public static final SuggestionProperty PROP_DETAILS =
        new SuggestionProperty(PROPID_DETAILS, String.class) {
            public Object getValue(Object obj) {
                // just delegate
                return TaskProperties.PROP_DETAILS.getValue(obj);
            }
        };

    public static final SuggestionProperty PROP_CATEGORY =
        new SuggestionProperty(PROPID_CATEGORY, String.class) {
            public Object getValue(Object obj) {
                return ((UserTask) obj).getCategory();
            }
        };

    public static final SuggestionProperty PROP_FILENAME =
        new SuggestionProperty(PROPID_FILENAME, String.class) {
            public Object getValue(Object obj) {
                return ((UserTask) obj).getFileBaseName();
            }
        };

    public static final SuggestionProperty PROP_LINE_NUMBER =
        new SuggestionProperty(PROPID_LINE_NUMBER, Integer.class) {
            public Object getValue(Object obj) {
                return new Integer(((UserTask) obj).getLineNumber());
            }
        };

    public static final SuggestionProperty PROP_CREATED_DATE =
        new SuggestionProperty(PROPID_CREATED_DATE, Date.class) {
            public Object getValue(Object obj) {
                return new Date(((UserTask) obj).getCreatedDate());
            }
        };

    public static final SuggestionProperty PROP_LAST_EDITED_DATE =
        new SuggestionProperty(PROPID_LAST_EDITED_DATE, Date.class) {
            public Object getValue(Object obj) {
                return new Date(((UserTask) obj).getLastEditedDate());
            }
        };

    public static final SuggestionProperty PROP_DUE_DATE =
        new SuggestionProperty(PROPID_DUE_DATE, Date.class) {
            public Object getValue(Object obj) {
                return ((UserTask) obj).getDueDate();
            }
        };

    public static final SuggestionProperty PROP_DONE =
        new SuggestionProperty(PROPID_DONE, Boolean.class) {
            public Object getValue(Object obj) {
                return Boolean.valueOf(((UserTask) obj).isDone());
            }
        };

    public static final SuggestionProperty PROP_PERCENT_COMPLETE =
        new SuggestionProperty(PROPID_PERCENT_COMPLETE, Integer.class) {
            public Object getValue(Object obj) {
                return new Integer(((UserTask) obj).getPercentComplete());
            }
        };

    public static final SuggestionProperty PROP_EFFORT =
        new SuggestionProperty(PROPID_EFFORT, Integer.class) {
            public Object getValue(Object obj) {
                return new Integer(((UserTask) obj).getEffort());
            }
        };

    public static final SuggestionProperty PROP_REMAINING_EFFORT =
        new SuggestionProperty(PROPID_REMAINING_EFFORT, Integer.class) {
            public Object getValue(Object obj) {
                return new Integer(((UserTask) obj).getRemainingEffort());
            }
        };

    public static final SuggestionProperty PROP_SPENT_TIME =
        new SuggestionProperty(PROPID_SPENT_TIME, Integer.class) {
            public Object getValue(Object obj) {
                return new Integer(((UserTask) obj).getSpentTime());
            }
        };

    public static SuggestionProperty getProperty(String propID) {
        if (propID.equals(PROPID_CATEGORY)) {
            return PROP_CATEGORY;
        } else if (propID.equals(PROPID_FILENAME)) {
            return PROP_FILENAME;
        } else if (propID.equals(PROPID_LINE_NUMBER)) {
            return PROP_LINE_NUMBER;
        } else if (propID.equals(PROPID_CREATED_DATE)) {
            return PROP_CREATED_DATE;
        } else if (propID.equals(PROPID_LAST_EDITED_DATE)) {
            return PROP_LAST_EDITED_DATE;
        } else if (propID.equals(PROPID_DUE_DATE)) {
            return PROP_DUE_DATE;
        } else if (propID.equals(PROPID_DONE)) {
            return PROP_DONE;
        } else if (propID.equals(PROPID_PERCENT_COMPLETE)) {
            return PROP_PERCENT_COMPLETE;
        } else if (propID.equals(PROPID_EFFORT)) {
            return PROP_EFFORT;
        } else if (propID.equals(PROPID_REMAINING_EFFORT)) {
            return PROP_REMAINING_EFFORT;
        } else if (propID.equals(PROPID_SPENT_TIME)) {
            return PROP_SPENT_TIME;
        } else if (propID.equals(PROPID_DETAILS)) {
            return PROP_DETAILS;
        } else {
            return TaskProperties.getProperty(propID);
        }
    }
}
... 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.