⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 humanresource.java

📁 It is all about project scheduling. GanttProject is a tool for creating a project schedule by means
💻 JAVA
字号:
/* * HumanResource.java * * Created on 27. Mai 2003, 22:19 */package net.sourceforge.ganttproject.resource;import java.util.Enumeration;import java.util.HashMap;import java.util.Hashtable;import java.util.Map;import javax.swing.DefaultListModel;import net.sourceforge.ganttproject.calendar.GanttDaysOff;import net.sourceforge.ganttproject.language.GanttLanguage;import net.sourceforge.ganttproject.roles.Role;import net.sourceforge.ganttproject.task.ResourceAssignment;/** * @author barmeier */public class HumanResource extends ProjectResource {	private boolean areEventsEnabled = true;	    private String phone = "";    private String email = "";        private String lineNumber = "" ;     private int function;    private Role myRole;    private final DefaultListModel myDaysOffList = new DefaultListModel ();        /* contains all the custom property values of a resource.     * the key is the property name and the value is the property value */    private final Map customFields;        private final HumanResourceManager myManager;    HumanResource(HumanResourceManager manager) {        this.name = "";        customFields = new HashMap(manager.getCustomFields());        myManager = manager;        // added    }    /** Creates a new instance of HumanResource */    HumanResource(String name, int id, HumanResourceManager manager) {    	super(id);        this.name = name;        customFields = new HashMap(manager.getCustomFields());        myManager = manager;    }    private HumanResource(HumanResource copy) {    	areEventsEnabled = false;		setId(-1);		setName(GanttLanguage.getInstance().getText("copy2")+"_"+copy.getName());		setCostsPerUnit(copy.getCostsPerUnit());		setDescription(copy.getDescription());		setMaximumUnitsPerDay(copy.getMaximumUnitsPerDay());		setUnitMeasure(copy.getUnitMeasure());		setMail(copy.getMail());		setPhone(copy.getPhone());		setRole(copy.getRole());		initCustomFields(copy.getCustomFields());		myManager = copy.myManager;		DefaultListModel copyDaysOff = copy.getDaysOff();		for (int i=0; i<copyDaysOff.getSize(); i++) {			myDaysOffList.addElement(copyDaysOff.get(i));		}		customFields = new HashMap(copy.customFields);		areEventsEnabled = true;    }     public void delete() {        super.delete();        myManager.remove(this);    }    public HumanResourceManager getResourceManager() {    	return this.myManager;    }        public void setMail(String email) {        this.email = email;        fireResourceChanged();    }    public String getMail() {        return email;    }    public void setPhone(String phone) {        this.phone = phone;        fireResourceChanged();    }    public String getPhone() {        return phone;    }    public void setLineNumber(String lineNumber){    	this.lineNumber = lineNumber;    	fireResourceChanged();    }	/** 	 * Calls the  countResNumber to get the	 * number of resources which will be set 	 * as the line Number when a resource is created.	 */    public void setLineNumber(){   	    	this.lineNumber = countResNumber();    	fireResourceChanged();    }        public String getLineNumber() {    	return lineNumber;    }                // public void setFunction (int function) {    // this.function=function;    // }    // public int getFunction () {    // return myRole==null ? 0 : myRole.getID();    // }    public void setRole(Role role) {        myRole = role;        fireResourceChanged();    }    public Role getRole() {        if (myRole == null) {            System.err                    .println("[HumanResource] getRole(): I have no role :( name="                            + getName());        }        return myRole;    }    public void addDaysOff(GanttDaysOff gdo) {        myDaysOffList.addElement(gdo);        fireResourceChanged();    }    public DefaultListModel getDaysOff() {        return myDaysOffList;    }        /* inits the customFields by the given hashtable */    public void initCustomFields(Map source) {    	customFields.putAll(source);    }        public Map getCustomFields() {    	return customFields;    }        public boolean hasCustomFields() {    	return !customFields.isEmpty();    }        public void addCustomField(String title, Object value) {    	this.customFields.put(title,value);    }        public void removeCustomField(String title) {    	this.customFields.remove(title);    }        public Object getCustomFieldVal(String title) {    	return customFields.get(title);    }        public void setCustomFieldVal(String title, Object val) {    	this.customFields.put(title,val);    }    public ResourceAssignment createAssignment(ResourceAssignment assignmentToTask) {        ResourceAssignment result = super.createAssignment(assignmentToTask);        fireAssignmentsChanged();        return result;    }            public ProjectResource unpluggedClone() {    	return new HumanResource(this);    }	/** 	 * count the number of resources	 *	 * @return return the number of resources + 1	 * 			to start the line number at 1.	 */    public  String countResNumber(){    	return myManager.getResources().size()+ 1 + "";    	    }        private void fireResourceChanged() {    	if (areEventsEnabled) {    		myManager.fireResourceChanged(this);    	}    }        protected void fireAssignmentsChanged() {        if (areEventsEnabled) {            myManager.fireAssignmentsChanged(this);        }            }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -